This utility is designed as easy-rsa replacement.
Comes with ease of use and sane defaults.
It's a wrapper around OpenSSL API to:
- create a self-signed CA
- create server certificates
- create client certificates and optionally pack them to ZIP files along with the OpenVPN config
- revoke the certificates when needed
It also can be used to manage a non-OpenVPN or non-self signed CA.
Installation
- Get Ruby (3.0 or greater is supported)
- Run
gem install ovpn-key
Usage
-
ovpn-key --initto initialize current directory
orovpn-key --init some/dirto create the working directory - edit the
ovpn-key.yml(see docs) ovpn-key --caovpn-key --server --nopassovpn-key --client somebody --nopassovpn-key --revoke somebody
--server
You can have multiple servers. You can omit the name and it will be just server.crt.
--nopass
Don't encrypt .key files with a passphrase. It can be used with --ca, --server, --client or --zip.
You'll want to have your CA key encrypted. If ovpn-key is run just from the trunk of the OpenVPN server, you'll likely want server's key unencrypted. Client keys are advised to be encrypted if used interactively. Use a different passphrase for different keys.
ZIP files
Add client OpenVPN configuration with .ovpn extension to the directory.
There should be only one. It should contain every setting except for cert and key.
Then you can use ovpn-key --zip somebody to generate a ZIP file
that the end user can easily import in his VPN client without any modifications.
The file will be named somebody.tblk.zip (if you specified somebody as name)
and would be written in zip_dir (home directory by default).
It will contain:
ca.crt- user's VPN configuration
- user's certificate and key, latter being encrypted with a passphrase unless
--nopasswas used -
ta.keyif it exists
Additional helpers
-
ovpn-key --staticgenerates a static unencrypted key:ta.key, intended to be used astls-crypt-v2/tls-crypt/tls-authpre-shared secret. -
ovpn-key --dhgenerates adh.pemfile. Its' usage is discouraged to use in modern OpenVPN configurations in favor of ECDH.
Configuration
It's just a single simple YAML file named ovpn-key.yml.
ovpn-key also processes ~/.ovpn-key.yml file, it has only one possible setting:
cd: ~/some/pathThis setting is used as a default directory if:
- current directory does not have
ovpn-key.yml -
--initis not specified
If you specify the default directory, you don't need to travel to it every time you want to launch ovpn-key, i.e. you can sign and revoke certs without traveling to the directory with certs.
CA variants supported
We still support the old RSA mode, but it's not recommended to use in new configurations, NIST curves are recommended if you're starting afresh at the moment, unless you have a very legacy deployment.
- OpenVPN 2.4+ supports NIST curves
- RHEL 8+ supports NIST curves
- Ubuntu 20+ supports NIST curves
Thus, we expect all current and even some EOL systems to support NIST curves that we use by default.
Example configurations:
NIST P-384, default since v1.0
key_type: secp384r1
digest: SHA384NIST P-521, probably an overkill
key_type: secp521r1
digest: SHA512NIST P-256, the fastest
key_type: secp256r1
digest: SHA256ed25519, least compatible
key_type: ed25519
#digest: not usedRSA 3K, a compromise if you still require RSA
#key_type: # commented out
key_size: 3072
digest: SHA256RSA 4K, the slowest
#key_type: # commented out
key_size: 4096
digest: SHA384Note: your configuration might still use the 2K RSA, this will work, but we recommend to phase out those deployments, as they're currently under NIST baseline.
Mixed mode
You can start your CA as RSA and generate newer keys in ECC.
Uncomment the key_type before you need the ECC key and that's it.
Usage with a non-self-signed CA
Place your ca.key and ca.crt in the keys directory and skip the --ca step.