Certificate based VPN
CGW has the option to use certificates for VPN connections.
To use these, the certificates and keys have to be managed as Kubernetes secrets. These will then be mounted into the CGW pod.
To configure CGW to use secrets for VPN connections there are two steps to fulfill:
- concert the certificates and keys to secrets
- configure Strongswan to use these
prerequisites
To follow this tutorial it is assumed, that the following components are already available:
- the certificate of the CA is available which signs the trusted keys
- a private/public-key-pair is created for this instance of the CGW
- a certificate signing request (CSR) was created
- the keys were signed and the certificate is available
The Strongswan DocumentationOpens in a new tab can be used as a starting point to learn how to create keys and certificates.
enable mounting of certificates
Set the following parameters to enable mounting of certificates to be used in later configurations:
manage secrets
There are four different kinds of data, which are managed in secrets and are part of the certificate based VPN configuration:
- public/private keys
- certificates
- CA certificates
- certificate revocation lists
All these files follow the same schema.
define secrets for certificates and keys
To configure CGW to use the certificates and keys you have stored on you harddrive, you have to add them to the configuration:
If a one of the four categories are not defined, no secret for the corresponding category will be defined and no folder will be mounted.
convert certificates and keys into secrets
To convert you files to a base64 encoded string you can use the following in your shell:
set up secrets manually
You can also create the secrets to store your certificates manually, for example to keep them outside of your values files.
To do so you first have to create a secret:
Then you have to store it to a file and apply it to your kubernetes cluster:
After that, you have to configure the certificate name in the CGW configuration:
The same applies for the values:
externalCertificatesexternalCertificateRevocationListsexternalPrivateKeys
NOTE: If the files are defined in the value files as well as external certificates are set, the external ones will preferred:
It is though recommended to delete or comment the unused part out.
configure strongswan
The following explainations are considering the strongswan configurations and secerts.
The main README describes how to set up the manual configuration.
setting up the CA
Concerning the Strongswan DocumentationOpens in a new tab the setup of a CA section in the configuration file is optional.
All CA certificates which are defined as described above will be automatically loaded.
It can be configured though add URIs of CRLs os OCSP for online verification of certificates.
configure connections
To configure a connection to a peer in a site-to-site scenario you have to set the corresponding ids and
certificates in the corresponding ipsec.conf file:
ipsec.test.conf:
When no rightid is given, it is taken from the certificate itself.
Further a defined id has to match the id in the certificate.
For futher information about configuration of connections refer to the Strongswan DocumentationOpens in a new tab
setting the private key
The private key to be used by the CGW has to be define in the ipsec.secrets file:
ipsec.test.secrets:
For futher information about configuration of secrets refer to the Strongswan DocumentationOpens in a new tab