`vault-openvpn` is a small wrapper utility to manage [OpenVPN](https://openvpn.net/) configuration combined with a [Vault PKI](https://www.vaultproject.io/docs/secrets/pki/index.html). It enables administrators with Vault access to create client / server configurations with only one command. No more hazzle to manage that easyrsa PKI, just some few commands to set up a Vault PKI and you're done.
## Setting up Vault for this
The Vault setup follows the Quick Start from the Vault documentation and is personalized for me so you need to adapt it to your domain if you want to follow it:
You can pass all configurations through commandline-parameters. To see the available options and their defaults use the `vault-openvpn --help` flag.
Additionally most of the parameters are also supported to be set using a configuration file to be stored in `~/.config/vault-openvpn.yaml`. To use that file you need to specify the arguments to the flags together with the flag name:
```yaml
---
log-level: debug
template-path: /path/to/templates
```
The flags not supported to be set through that file are `vault-addr`, `vault-token` and `version`. First two for security reasons, last because it does not make sense.
You need to create a folder containing two files: `client.conf` and `server.conf`. Those two are templates to use for generating the configuration file used by `vault-openvpn`. Inside those files paste this block which will get replaced by the certificates:
For the server configuration an additional block is available in case you don't want to generate your DH parameters with an external command:
```
<dh>
{{ dhparam <bitsize> [generator] }}
</dh>
```
In this function call you must specify `<bitsize>` (for example `2048`) and may specify the `[generator]`. If the generator is not specified the default generator is set to `2`. Please ensure you are not using this block in your `client.conf` as OpenVPN will not accept it there.
The configurations generated by this tool will not need multiple files but include the certificates inside the configuration. This makes it far more easy to pass them to your users. No unzip, no questions where to put the files, mostly the OpenVPN clients will know how to handle something called `my-vpn.conf`.
After you've set up your folder (you also could use one of the example configurations in the [`example` folder](https://github.com/Luzifer/vault-openvpn/tree/master/example) of this repository) you can issue your servers configuration:
To have revokes being executed by OpenVPN you need to periodically update the CRL file OpenVPN reads. For my solution see the `living-example` in the `example` folder.
OpenVPN highly recommends using TLS authentication hardening, see [GettingStartedwithOVPN](https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN#TLSAuthentication).
This requires the use of a pre-shared key: If you want to use it, you will first need to generate a TLS authentication key and then upload it into vault:
Mind the additional `/data` added inside the key directly after the mount. This is required due to the differences in API methods between the KV v1 and v2 backends.