vault-helm: HA vault init with TLS - cannot validate certificate
Hello,
I’m trying to setup HA vault cluster consisting of 3 vault pods in EKS.
I followed the TLS cert generation instructions from https://www.vaultproject.io/docs/platform/k8s/helm/examples/standalone-tls/
When I try to run vault operator init, vault is returning:
Error initializing: Put https://127.0.0.1:8200/v1/sys/init: x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs
In my csr.conf, I have these defined:
[alt_names]
DNS.1 = vault
DNS.2 = vault.vault
DNS.3 = vault.vault.svc
DNS.4 = vault.vault.svc.cluster.local
IP.1 = 127.0.0.1
I also checked the csr generated:
X509v3 Subject Alternative Name:
DNS:vault, DNS:vault.vault, DNS:vault.vault.svc, DNS:vault.vault.svc.cluster.local, IP Address:127.0.0.1
I suspect 127.0.0.1 is from the env variable defined in the statefulset template
- name: VAULT_ADDR
value: "{{ include "vault.scheme" . }}://127.0.0.1:8200"
- name: VAULT_API_ADDR
value: "{{ include "vault.scheme" . }}://$(POD_IP):8200"
My tcp listener is configured as:
listener "tcp" {
address = "[::]:8200"
cluster_address = "[::]:8201"
tls_cert_file = "/vault/userconfig/vault-server-tls/vault.crt"
tls_key_file = "/vault/userconfig/vault-server-tls/vault.key"
tls_client_ca_file = "/vault/userconfig/vault-server-tls/vault.ca"
}
Is there another set of instructions I am missing?
Thanks
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 19 (1 by maintainers)
Commits related to this issue
- Update helm standalone TLS doc for k8s 1.22 The `CertificateSigningRequest` for `v1beta1` API is no longer available, and now requires the `signerName` parameter. Many thanks to @DavidRBanks for the... — committed to hashicorp/vault by deleted user 2 years ago
- Update helm standalone TLS doc for k8s 1.22 (#16029) Update helm standalone TLS doc for k8s 1.22 The `CertificateSigningRequest` for `v1beta1` API is no longer available, and now requires the `si... — committed to hashicorp/vault by swenson 2 years ago
- Update helm standalone TLS doc for k8s 1.22 (#16029) Update helm standalone TLS doc for k8s 1.22 The `CertificateSigningRequest` for `v1beta1` API is no longer available, and now requires the `signe... — committed to hashicorp/vault by swenson 2 years ago
- Update helm standalone TLS doc for k8s 1.22 (#16029) (#16043) Update helm standalone TLS doc for k8s 1.22 The `CertificateSigningRequest` for `v1beta1` API is no longer available, and now require... — committed to hashicorp/vault by hc-github-team-secure-vault-core 2 years ago
For anyone running across this who happens to be following the documentation in a cluster running 1.22 or greater, with the changes to the certificate API, you will need to make some changes.
First, for the csr.yaml file you will need a
signerName. Reference the documentation here for a TLS cert. You will want to usesignerName: kubernetes.io/kubelet-servingfor the server cert. That being said, you’ll need to modify the command in the vault documentation to include the organization and common name requirements for that signerName, as mentioned here.You’ll know if you’re dealing with this problem if your certificate immediately goes to the
Approved,Failedstatus when you approve the csr. The way I solved this was to modify the command to create the server.cert by using the following command. This sets the organization and common names to align with the requirements for this signer:openssl req -new -key ${TMPDIR}/vault.key -subj "/O=system:nodes/CN=system:node:${SERVICE}.${NAMESPACE}.svc" -out ${TMPDIR}/server.csr -config ${TMPDIR}/csr.conf@j-sokol Thank you so much for the tip that certificates need to be provided this way, worked for me!!
In case anyone like me stumbles across this feel free to use my whole config, which works with the fixes described in this thread:
Using wildcard certificate as @ikarlashov noted worked for me.
One thing to mention, when joining the cluster from
vault-1andvault-2pods, key, cert and ca-cert have to be provided:where env variables above are set in Helm chart’s values:
Also, certificates have to be configured in
server.ha.raft.config.Just faced this issue today. You need to generate csr with the following config:
where
Then you can do:
vault operator init -address https://vault-0.vault-internal.vault.svc.cluster.local:8200That’s it 😃
it is possible to set specific server name which will be used in TLS handshake
ref. https://www.vaultproject.io/docs/concepts/integrated-storage#autojoin-with-tls-servername