Set up a certificate-based VPN
CGW has the option to use certificates for VPN connections. To use them, the certificates and keys must be managed as Kubernetes Secrets. These Secrets are later mounted into the CGW pod.
To configure CGW to use Secrets for VPN connections, there are two steps to fulfil:
- Convert the certificates and keys to Secrets.
- Configure strongSwan to use Secrets.
Prerequisites
- Certificate of the CA, which signs the trusted keys, is available
- Private/public key-pair is created for this instance of CGW
- Certificate signing request (CSR) was created
- Keys were signed and the certificate is available
Use strongSwan documentationOpens in a new tab 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:
Manage Secrets
There are four different kinds of data that 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 store on you hard drive, add them to the configuration:
If one of the four categories are not defined, no Secret for the corresponding category is defined and no folder is mounted.
Convert certificates and keys into Secrets
To convert your files to a base64-encoded string, use the following command 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, create a Secret:
Then, store it to a file and apply it to your Kubernetes cluster:
After that, configure the certificate name in the CGW configuration:
The same applies to the following values:
externalCertificatesexternalCertificateRevocationListsexternalPrivateKeys
If the files are defined in the values files and the external certificates are set, the external certificates are preferred. It is though recommended to delete or comment the unused part out. See the example:
Configure strongSwan
The following sections describe the strongSwan configurations and Secrets. The Set up a VPN connection with IPsec tutorial describes how to set up the manual configuration.
Setting up the CA
According to the strongSwan documentationOpens in a new tab, the setup of a CA section in the configuration file is optional. All defined CA certificates are automatically loaded.
If you want to configure the CA section, add URIs of CRLs or OCSP for online verification of certificates.
Configure connections
To configure a connection to a peer in a site-to-site scenario, 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. The defined ID must match the ID from the certificate.
For more information about configuration of connections, refer to the strongSwan documentationOpens in a new tab.
Setting the private key
Define the private key that should be used by CGW in the ipsec.secrets file:
ipsec.test.secrets:
For more information about configuration of Secrets, refer to the strongSwan documentationOpens in a new tab.