Project

ovpn-key

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
ovpn-key is a modern, easy-to-use alternative to Easy-RSA for managing OpenVPN PKI. It provides sensible security defaults and streamlined workflows for creating certificate authorities, issuing and revoking certificates, and managing keys and certificates. Unlike tools that shell out to the openssl command-line utility, ovpn-key uses the OpenSSL API directly through Ruby bindings.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 3.0
 Project Readme

ovpn-key: key management for OpenVPN Gem Version

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

  1. Get Ruby (3.0 or greater is supported)
  2. Run gem install ovpn-key

Usage

  1. ovpn-key --init to initialize current directory
    or ovpn-key --init some/dir to create the working directory
  2. edit the ovpn-key.yml (see docs)
  3. ovpn-key --ca
  4. ovpn-key --server --nopass
  5. ovpn-key --client somebody --nopass
  6. ovpn-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:

  1. ca.crt
  2. user's VPN configuration
  3. user's certificate and key, latter being encrypted with a passphrase unless --nopass was used
  4. ta.key if it exists

Additional helpers

  • ovpn-key --static generates a static unencrypted key: ta.key, intended to be used as tls-crypt-v2/tls-crypt/tls-auth pre-shared secret.
  • ovpn-key --dh generates a dh.pem file. 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/path

This setting is used as a default directory if:

  1. current directory does not have ovpn-key.yml
  2. --init is 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.

  1. OpenVPN 2.4+ supports NIST curves
  2. RHEL 8+ supports NIST curves
  3. 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:   SHA384

NIST P-521, probably an overkill

key_type: secp521r1
digest:   SHA512

NIST P-256, the fastest

key_type: secp256r1
digest:   SHA256

ed25519, least compatible

key_type: ed25519
#digest:  not used

RSA 3K, a compromise if you still require RSA

#key_type: # commented out
key_size: 3072
digest:   SHA256

RSA 4K, the slowest

#key_type: # commented out
key_size: 4096
digest:   SHA384

Note: 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.