kylemanna / docker-openvpn

🔒 OpenVPN server in a Docker container complete with an EasyRSA PKI CA
https://hub.docker.com/r/kylemanna/openvpn/
MIT License
8.68k stars 2.38k forks source link

4096 bit keys #445

Open Biepa opened 5 years ago

Biepa commented 5 years ago

Hey,

i want to generate 4096 keys. Regarding #154 i added "declare -x EASYRSA_KEY_SIZE=4096" to ovpn_env.sh

Do i need to reinitialize something?

docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME generates still 2048 bit keys.

docker-compose run -e EASYRSA_KEY_SIZE=4096 --rm openvpn easyrsa build-client-full $CLIENTNAME gets me 4096 bit keys

But when i export in .ovpn file, the content of ovpn_env.sh is written in the ovpn file and then the config doesnt work. When i manually remove those lines, the config works as expected.

Does somebody know, where I am wrong?

Amaelh commented 5 years ago

To generate a 4096 bit key the parameter has to be added to the command initialising the server part : docker-compose run --rm -e EASYRSA_KEY_SIZE=4096 rpi-openvpn sh -c "ovpn_initpki"

On my side I added the following parameters directly in docker-compose.yml : environment:

Biepa commented 5 years ago

@Amaelh Hey, thank you for your answer. i tried as you said, and the initial process worked so far.

But when I use the "build-client-full" command I still get all those config paramters in the ovpn file.

`+ set -e

remote vpn.domain.de 1194 udp'

client nobind dev tun remote-cert-tls server

remote vpn.domain.de 1194 udp

-----BEGIN ENCRYPTED PRIVATE KEY----- omitted -----END ENCRYPTED PRIVATE KEY----- -----BEGIN CERTIFICATE----- omitted -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- omitted -----END CERTIFICATE-----

key-direction 1

# # 2048 bit OpenVPN static key # -----BEGIN OpenVPN Static key V1----- omitted -----END OpenVPN Static key V1-----
Amaelh commented 5 years ago

Well I have the same on my side : the ta.key file mentions a 2048 bit length in comments. Only my ca.crt is generated with 4096 bits :

bash-4.4# openssl x509 -text -noout -in ca.crt
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            ....
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN=vpn.domain.ltd
        Validity
            Not Before: ...
            Not After : ...
        Subject: CN=vpn.domain.ltd
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (4096 bit)

I guess we'll need another opinion here