How to write a VPN server [closed]
Asked Answered
C

1

35

I have decided to write my own light weight VPN server in Java. From a programming standpoint it appears to me a VPN server is just a pass-through proxy that encrypts traffic from the client, and decrypts it on the server. Can someone point me to a skeleton of writing this sort of server?

I know there are many out of the box and even open source ones, but unfortunately even though I know several web programming languages the C code examples I have seen is not documented/structured in such a way that I can understand it.

The parts I would Imagine I need are:

  • A thread factory for client objects
  • A socket connector for clients
  • Method for creating IPSec Authentication Header (AH)
  • Method for creating IPSec Encapsulating Security Payload (ESP)
  • Something for Internet Security Association and Key Management Protocol (ISAKMP)
  • An Internet Key Exchange (IKE)
  • PKI Certificate Authentication modules
  • A Certificate Repository (SQLLite)
  • Oakley key generation (for IKE and ISAKMP)
  • Some Anti-replay prevention of packets

The parts I plan to use generic modules for (and create adapters for) are the Cryptographic Algorythms (AES preferably although it appears that windows like DES / 3DES -- Noobs)

If someone can add more detail to the parts that are necessary for an IPSec vpn server please feel free to contribute. Since it is necessary to run this on older linux hardware from what I can tell, the server should be IPSec as opposed to an SSLVPN hotness. The target platform is an old 1.5 Ghz intel box that I pumped up with 2 GB of DDR2 ram, mirrored 100 GB hard drive and 2 Gigabit Nic's.

On the bright side since there are so many types of client-side VPN's I am pretty sure that do not need to make one for my needs.

Choleric answered 9/6, 2011 at 3:40 Comment(10)
This is a MUCH larger task than you are imagining. Why can't you use OpenVPN?Kiangsu
Actually it is not. I actually have several enterprise applications I have written (such as workflow modules, home made proxies, SHA1 password digest authentication modules, etc.) The last App I wrote was around 28k lines of code when it hit beta. So rather than attack me, how about answering the questions or pointing me to a useful resource instead of flaming and closing a valid post.Choleric
Calm down. I didn't vote to close, and my question is one anybody would ask when someone wants to solve an already-solved problem.Kiangsu
Nice question, too sad it's closed. I need the answer too.Pheasant
maybe as a learning exercise? thats why i would want to do it. plus its fun. Using that logic why would anyone build anything? as most orginal app ideas have already been takenDelainedelainey
sample vpn server (300 lines) and android client android.googlesource.com/platform/development/+/master/samples/…Disaccredit
Also bummed this got closed. Valid question. We want to reinvent the wheel because we're curious; that's how we learn why things work and how to improve them.Bathroom
i think this type of info and software protocol white papers are being disappeared of the internet by big tech. i hate to go all conspiracy but what is one way to eliminate competition? remove the easy access to the knowledge base from the general public.Delainedelainey
RFC-2764 A Framework for IP Based Virtual Private NetworksNovikoff
@Choleric Did you ever find the guide/framework you were looking for? I was wanting to do something similar as a personal projectPortsalut
A
1

I'd start by looking at OpenVPN source code. It's not java, but should be enough to understand the principles.

Atomic answered 9/6, 2011 at 3:44 Comment(2)
Yep, as I mentioned I did that already and while I understood large chunks of the code I was looking for some sort of outline (book resources, articles, etc.) or some other general guidelines since there were some part's that were too obscure / undocumented to really understand.Choleric
Did you ever figure out how to do this @Dave?Achorn

© 2022 - 2024 — McMap. All rights reserved.