Simplified recap of certain concepts
Certificates
A certificate on a server has 2 parts — the private key and the public certificate. The public certificate is sent to the client which has the identity of the server. The client “trusts” that the certificate offered to it is genuine and not a malicious masquerader by checking whether it trusts the signer/certificate authority of the certificate. Well known certificate authorities share the public certificates of their signing key to popular operating systems and browsers.
Self-signed vs CA signed certificates
If a certificate is self-signed, the only way to trust it securely is to share the public certificate with the client beforehand which has scalability challenges when multiple services are present. A CA signed certificate on the other hand only requires the public certificate of the CA to be distributed beforehand and all certificates signed using that CA are then implicitly trusted.
Why can’t we use a well known free CA like Let’s Encrypt
Well-known CA’s use the ACME protocol while generating automated certificates that contains a validation step to check whether the certificate requestor is a rightful owner of the host for which the certificate is being requested. The hosts in the use case of services running within a Kubernetes cluster are all local and cannot be validated by an external authority.
Scenario Conditions
- Host a mongodb cluster in namespace mongo with TLS encryption enabled.
- Multiple clients of the mongodb cluster running in different namespaces of the cluster.
Solution
Prerequisites
- Deploy cert-manager. For the scope of this blog, let’s assume the namespace in which it is deployed to be cert-manager
- Deploy trust in the same namespace as cert-manager
- Have an understanding of Issuers and ClusterIssuers. You can read about them here
Creating an issuer for the CA certificate
The key pair of the root CA needs to be created. To implement it in a model that is scalable across multiple environments, it is best to have cert-manager create it. Deploy the following manifest