If you choose to provide your own CA root certificate and key, you can use the provided
backend. With this option, you must also manage the certificate lifecycle yourself.
Unlike the builtin
backend, with provided
you first upload the certificate and key as Secret resource, and then reference the Secrets in the mTLS configuration.
Kong Mesh then provisions data plane proxy certificates for every replica of every service from the CA root certificate and key.
Sample configuration:
apiVersion: kuma.io/v1alpha1
kind: Mesh
metadata:
name: default
spec:
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: provided
dpCert:
rotation:
expiration: 1d
conf:
cert:
secret: name-of-secret
key:
secret: name-of-secret
We will apply the configuration with kubectl apply -f [..]
.
type: Mesh
name: default
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: provided
dpCert:
rotation:
expiration: 1d
conf:
cert:
secret: name-of-secret
key:
secret: name-of-secret
We will apply the configuration with kumactl apply -f [..]
or via the HTTP API.
A few considerations:
- The
dpCert
configuration determines how often Kong Mesh should automatically rotate the certificates assigned to every data plane proxy.
- The Secrets must exist before referencing them in a
provided
backend.
You can also work with an Intermediate CA with a provided
backend. Generate the certificate and place it first in certificate file, before the certificate from the root CA. The certificate from the root CA should start on a new line. Then create the secret to specify in the cert
section of the config. The secret for the key
should contain only the private key of the certificate from the intermediate CA.
You can chain certificates from multiple intermediate CAs the same way. Place the certificate from the closest CA at the top of the cert file, followed by certificates in order up the certificate chain, then generate the secret to hold the contents of the file.
Sample certificate file for a single intermediate CA:
-----BEGIN CERTIFICATE-----
MIIDdjCCAl6gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCR0Ix
EDAOBgNVBAgMB0VuZ2xhbmQxEjAQBgNVBAoMCUFsaWNlIEx0ZDEPMA0GA1UEAwwG
S3VtYUNBMB4XDTIxMDUxMjEzMzU1MVoXDTMxMDUxMDEzMzU1MVowUDELMAkGA1UE
BhMCR0IxEDAOBgNVBAgMB0VuZ2xhbmQxEjAQBgNVBAoMCUFsaWNlIEx0ZDEbMBkG
A1UEAwwSS3VtYUludGVybWVkaWF0ZUNBMIIBIjANB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-----END CERTIFICATE-----
When using an arbitrary certificate and key for a provided
backend, we must make sure that we comply with the following requirements:
- It MUST have basic constraint
CA
set to true
(see X509-SVID: 4.1. Basic Constraints)
- It MUST have key usage extension
keyCertSign
set (see X509-SVID: 4.3. Key Usage)
- It MUST NOT have key usage extension ‘keyAgreement’ set (see X509-SVID: Appendix A. X.509 Field Reference)
- It SHOULD NOT set key usage extension ‘digitalSignature’ and ‘keyEncipherment’ to be SPIFFE compliant (see X509-SVID: Appendix A. X.509 Field Reference)
Do not use the following example in production, instead generate valid and compliant certificates. This example is intended for usage in a development environment.
Below we can find an example to generate a sample CA certificate + key:
The following command will generate a CA root certificate and key that can be uploaded to Kong Mesh as a Secret and then used in a provided
mTLS backend:
SAMPLE_CA_CONFIG="
[req]
distinguished_name=dn
[ dn ]
[ ext ]
basicConstraints=CA:TRUE,pathlen:0
keyUsage=keyCertSign
"
openssl req -config <(echo "$SAMPLE_CA_CONFIG") -new -newkey rsa:2048 -nodes \
-subj "/CN=Hello" -x509 -extensions ext -keyout key.pem -out crt.pem
The command will generate a certificate at crt.pem
and the key at key.pem
. We can generate the Kong Mesh Secret resources by following the Secret resource.
In development mode we may want to provide the cert
and key
properties of the provided
backend without necessarily having to create a Secret resource, but by using an inline value.
Using the inline
modes in production presents a security risk since it makes the values of our CA root certificate and key more easily accessible from a malicious actor. We highly recommend using inline
only in development mode.
Kong Mesh offers an alternative way to specify the CA root certificate and key:
Please note the inline
properties that are being used instead of secret
:
apiVersion: kuma.io/v1alpha1
kind: Mesh
metadata:
name: default
spec:
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: provided
conf:
cert:
inline: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURHekNDQWdPZ0F3S... # cert in Base64
key:
inline: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURHekNDQWdPZ0F3S... # key in Base64
Please note the inline
properties that are being used instead of secret
:
type: Mesh
name: default
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: provided
conf:
cert:
inline: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURHekNDQWdPZ0F3S... # cert in Base64
key:
inline: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURHekNDQWdPZ0F3S... # cert in Base64