-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DER and PEM support #1
Conversation
Cool writeup 😁 Might be sort-of related to cert-manager/cert-manager#4598 ? I guess this is a more generally useful thing for k8s! 🤔 |
From what it seems like, adding a static |
I added the use-cases to the readme (3bbaaba) and also added a link to the PR cert-manager/cert-manager#4598 that implements DER key and combined PEM. I'll close this PR now since there is no point in trying to implement the DER key transformation since it is being implemented in cert-manager itself. |
Would this cover the use case that has been presented regarding Redis? There are format differences between cert-manager generated secrets and what Redis expects. Details as follows: Cert-manager generated:
Redis expects:
|
Hi! Yes, you can use The only difference with the rest of the examples in the README is that you will need to create the Secret beforehand so that The pre-created Secret I suggest is: apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: redis-cert1
annotations:
cert-manager.io/secret-copy-tls.crt: certificate
cert-manager.io/secret-copy-tls.key: key
data:
name: proxy After cert-manager has issued the certificate, it will have added the apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: redis-cert1
annotations:
cert-manager.io/secret-copy-tls.crt: certificate
cert-manager.io/secret-copy-tls.key: key
data:
tls.crt: LS0tLCR...UdJ0tC7g==
tls.key: CRUdJTo...Ci0tLS0t==
ca.crt: Ci0tLS0t...CRUdJTo==
name: proxy Right after that, secret-transform copies apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: redis-cert1
annotations:
cert-manager.io/secret-copy-tls.crt: certificate
cert-manager.io/secret-copy-tls.key: key
data:
tls.crt: LS0tLCR...UdJ0tC7g==
tls.key: CRUdJTo...Ci0tLS0t==
ca.crt: ...
certificate: LS0tLCR...UdJ0tC7g==
key: CRUdJTo...Ci0tLS0t==
name: proxy Does it make sense? |
At first, I wanted to "add features" (DER support); I quickly realized that I did not understand why this issue existed in the first place. I spent a few hours investigating why people have issues and need PKCS#12, JKS, PKCS#8 DER, combined PEM... I wrote the various "use-cases" that I found along the way. After this investigation, I found only two useful transformations:
Transform the
tls.key
into a PKCS#8-formated DER-encoded binary private key. To use this mode, annotate your Secret with the following annotations:Bundle together the
tls.key
andtls.crt
into a PEM-encoded concatenation of the PKCS#8-formated PEM-encoded private key followed by the chain of PEM-encoded X.509 certificates.The other use-cases aren't relevant since I did not find any pain point (that I could find on the cert-manager issues). Here are the use-cases I identified:
Use-case: MongoDB
cert-manager/cert-manager#843
In order to configure mTLS, the
mongod
andmongos
require a combined PEM file using the keycertificateKeyFile
. The PEM file must contain the PKCS#8 PEM-encoded private key followed by the chain of PEM-encoded X.509 certificates. The configuration looks like this:Use-case: HAProxy Community Edition and HAProxy Enterprise Edition
crt
parameter requires a PEM bundle containing the PKCS#8 private key followed by the X.509 certificate chain. An example of configuration looks like this:Use-case: Hitch
Hitch, a reverse-proxy that aims at terminating TLS connections, requires the use of a combined PEM bundle using the configuration key
pem-file
. The bundle must be comprised of a PKCS#8-encode private key followed by the X.509 certificate leaf followed by intermediate certificates. An example of configuration looks like this:or
Use-case: Postgres JBDC driver (lower than 42.2.9)
If you are stuck with a version of the Postgres JDBC driver older than 42.2.9 (released before Dec 2019),
sslkey
refers to a file containing the PKCS#8-formated DER-encoded private key.Use-case: Ejabbed
Related issue in the cert-manager repository: Add ca.crt to TLS secret generated by ACME issuers.
Ejabbed, an open-source Erlang-based XMPP server, requires all file paths given with
certfiles
to be "valid" (i.e., not empty). The pain point is that Ejabbed fails when theca.crt
file is empty on disk. This makes it difficult to use Ejabberd with cert-manager, for example with the following Ejabbed configuration:Use-case: Elasticsearch (Elastic's and Open Distro's)
Related to the issue on the cloud-on-k8s project: fleet and elastic agent doesn't work without a ca.crt.
Elasticsearch cannot start when the
ca.crt
file is empty on disk, which may happen for ACME issued certificates. A "possible" workaround for these emptyca.crt
could be to setpemtrustedcas_filepath
to the existing system CA bundle. For example, on REHL, that could be/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
or/etc/ssl/cert.pem
on Alpine Linux. But Elasticsearch expects this file to exist within its config path (i.e.,/usr/share/elasticsearch/config
).