Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenVPN 2.4 support #96

Closed
wants to merge 45 commits into from
Closed

OpenVPN 2.4 support #96

wants to merge 45 commits into from

Conversation

angristan
Copy link
Owner

This is WIP for adding OpenVPN 2.4 new features into the script

  • Add support for AES-GCM ciphers for the data channel
  • Add support for tls-crypt
  • Add support for ECDSA certificates
  • Add support for ECDHE
  • Add choice for HMAC auth algorithm
  • Add choice for certificate hash algorithm
  • Add choice for the control channel's cipher

All these options have an OpenVPN 2.3-compatible choice (example : RSA cert and DH key)

In my previous PR, I removed the encryptions choices to only choose the best ones. Here I've added the choice for every encryption parameter, as it seems that users prefer to use the script this way.

It seems to be working, I'll have to dome some more testing, rewrite some menus and then rewrite the readme with to add the new features.

- Add support for AES-GCM ciphers for the data channel
- Add support for tls-crypt
- Add support for ECDSA certificates
- Add support for ECDHE
- Add choice for HMAC auth algorithm
- Add choice for certificate hash algorithm
- Add choice for the control channel's cipher

All these options have an OpenVPN 2.3-compatible choice (example : RSA cert and DH key)
@angristan angristan self-assigned this Sep 14, 2017
@angristan angristan mentioned this pull request Sep 14, 2017
21 tasks
@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan Please take a look

screenshot 2017-09-14 001

@angristan
Copy link
Owner Author

Should be fixed now

@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan

screenshot 2017-09-14 002

@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan

My ISP resets connection, I am in restricted network.

2.4 branch is working for me - https://github.com/Angristan/OpenVPN-install/blob/openvpn-2.4/openvpn-install.sh

but actual PR is not.

There are 2 logs in attachment.

pc1 - current 2.4 branch

client1 - this PR.

If you need configs, I can attach them also.

client1.txt
pc1.txt

@angristan
Copy link
Owner Author

Please update your OpenVPN client.

Also, can you try with a RSA cert, DH key and tls-auth ?

@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan
Could you add this type of TLS-cipher to script, please?

TLS-DHE-RSA-WITH-AES-128-GCM-SHA256

@angristan
Copy link
Owner Author

Why ?

@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan
For test purposes.

I am not good at this. I understand there are to types of OpenVPN now:

  1. 2.3 - Old one, DH, RSA, tls-auth, AES-128/256-CBC
  2. 2.4 - New one, ECDHE-ECDSA, elliptic curves, GCM ciphers

Am I right?

@angristan
Copy link
Owner Author

Well you can add it yourself in the script or directly in your config files

@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan
I am trying to figure out, why script from openvpn-2.4 branch is working and script from this PR is not?
Difference in elliptic curves?

@angristan
Copy link
Owner Author

I'll try to make some tests on a W10 VM, it's strange indeed

@x0r2d2
Copy link

x0r2d2 commented Sep 14, 2017

@angristan
Definitely. the problem is in my network, I mean I need special config to make openvpn work in my network. They are trying to block openvpn tls traffic.

Thanks for your help. I will be glad to help you in tests.

From the OpenVPN wiki:

>Authenticate data channel packets and (if enabled) tls-auth control channel packets with HMAC using message digest algorithm alg. (The default is SHA1 ). HMAC is a commonly used message authentication algorithm (MAC) that uses a data string, a secure hash algorithm, and a key, to produce a digital signature.

>If an AEAD cipher mode (e.g. GCM) is chosen, the specified --auth algorithm is ignored for the data channel, and the authentication method of the AEAD cipher is used instead. Note that alg still specifies the digest used for tls-auth.

Tl;DR: if we're using an AEAD cipher (AES GCM), `auth alg` won't have inpact on the impact channel, but only on the control channel if tls-auth/tls-crypt is enabled.
Doesn't have any impact, but that's how it should be.
This seems like a little change but it was not easy to find.

I want this script to support only OpenVPN 2.4 servers, but also 2.4 and 2.3 clients.

The thing is, the OpenVPN 2.3 client doesn't care at all what cipher the server wants to use. The cipher parameter in the client config is the king here.

But with OpenVPN 2.4, you can specify whatever cipher you want, the clients and the server will negotiate the best cipher possible, which is AES-256-GCM right now. The use of --ncp-ciphers cipher_list is useless because a 2.3 client will still use its cipher and a 2.4 client will still use AES-256-GCM.

I won't detail all my experiments here, but in the end, ncp-disable disable the cipher negotiation for 2.4 clients. But it will only work if the cipher in the server config and the client config are the same, and as they are in the script, it's ok. This is not the best solution because that means if you want to support a 2.3 client, you'll be forced to use one and only one AES-CBC cipher, even with your 2.4 clients, even though you could use a different cipher for each client. But as we're still using AES and OpenVPN 2.4 getting more and more deployed, this is not a too big issue in the end. Also adding menus to to choose what kind of client you want etc would make the script pretty complicated, so this is a good compromise here.

TL;DR: ncp-disable enforces a OpenVPN 2.4 client to use the specified cipher in the server and the client config.

See here for me details regarding the data channel cipher negotiation in OpenVPN 2.4 : https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage#lbAJ
@x0r2d2
Copy link

x0r2d2 commented Sep 17, 2017

3

@angristan
Copy link
Owner Author

I appreciate your help, but can you please use words, too?

@emilio1625
Copy link

emilio1625 commented Jan 24, 2018

I have some question about how the script is managing iptables and firewalld specially on fedora:
Why it doesn't inform the user that firewalld is going to be disabled and even masked?
Why it doesn't stop the firewalld service?
From line 773
the changes to iptables are saved, then is checked whether is firewalld active, in fedora, it was not stopped, but on the next reboot it wont be present, and the rules that are passed to firewalld will not be applied on the next reboot.
In the next block where is check "if iptables has at least one REJECT rule" the iptables are never saved, and it makes use of sed to edit something, but i think $RCLOCAL is never declared.
I have this doubts because in my system firewalld is disabled, but not stopped, so the rules for the port work and i can connect, but as soon as i reboot, firewalld is not present anymore, and the rules for the port are not stored in iptables.rules, so i can't connect to the VPN, but it is saved the rule for the NAT.
Manually adding this

iptables -I INPUT -p udp --dport $PORT -j ACCEPT
iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables-save > $IPTABLES

fixed this problem and even some error messages when uninstalling.
Personally i think completely disabling firewalld and just using iptables would be more convinient.
But i missed something?, maybe I'm not understanding well how the script works, but i'm sure there's an issue there, I'm not uploading a PR because i think i could break something, if i don't understand what i'm i doing and why this is needed
Really sorry for my English

Thus we have the latest version.
@angristan
Copy link
Owner Author

@emilio1625 would adding systemctl stop firewalld around here fix this?

@angristan
Copy link
Owner Author

@cezar97 $CC_ENC is Control Channel Encryption. (!= data channel).
OpenVPN 2.3 support ECDHE and AES GCM for the CC, but not the DC.

Correcting these for v2.3 may still lead to a problem: the use of RSA with ECDHE and GCM on v2.4.

Why is it an issue?

@angristan
Copy link
Owner Author

Ok 👍

@angristan
Copy link
Owner Author

@cezar97 I already researched the subject and in the end NIST curves were still the best regarding security, speed and support. I agree they aren't the best, but what about client support? openvpn --show-curves doesn't work with OpenVPN < 2.4.
But yes this isn't an easy topic.

@emilio1625
Copy link

emilio1625 commented Mar 20, 2018

Hi, sorry for the late response, i added that line, and that fixed some error messages when installing and uninstalling, but the problem with the iptables not working was not fixed, again, i had to add the ip rules manually, i'll try to fix the issue this week

@mep85
Copy link

mep85 commented Apr 24, 2018

Is it possible to add a menu to update an old installation, enable new features, and then re-generate client files based on those preferences?

For example, let's suppose that I upgrade to 2.4 and I want to enable tls-crypt and change cyphers.

Or is the suggested upgrade path just to uninstall and then re-install if changes are desired?

@x0r2d2
Copy link

x0r2d2 commented May 9, 2018

@angristan
I can not create PR directly to this PR, so I created separate PR for TCP_NODELAY

@angristan
Copy link
Owner Author

Following #96 (comment): VORACLE is now a thing. So we will disable compression by default.

https://www.bleepingcomputer.com/news/security/voracle-attack-can-recover-http-data-from-vpn-connections/
https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16919.html

@angristan
Copy link
Owner Author

angristan commented Sep 22, 2018

Hello everyone,

Sorry this has taken so long. In the past week, I've worked dozens of hours on the project and rewrote a big part. A lot of features have been added, and a lot of stuff have been improved and fixed.

The master branch is so different than one year ago so this PR is pointless. I added the features one by one on master, and make sure it worked.

The original PR was about one and half year ago... But I finally made it. Also I've improved my skills quite a lot since then so it's not implemented the exact same way.

Anyway, here are the changes:

  • Add support for LZ4: b898a99
  • Add support for AES-GCM ciphers for the data channel: 10a1d04
  • Add support for tls-crypt: c2a502b
  • Add support for ECDSA certificates: 4d1baca
  • Add support for ECDH: 3a5e23c
  • Add choice for HMAC auth algorithm: bbdabed
  • Add choice for the control channel's cipher: 4d1baca
  • Support negotiable crypto parameters (NCP): 62c89af

Thanks for waiting 🙏

@angristan
Copy link
Owner Author

Updated the README: ba1fc42

@angristan angristan deleted the openvpn-2.4-update branch September 22, 2018 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants