TLS error in plugin registration

I get the following error when enabling a plugin. I appreciate help:

plugin tls init: error=“error during token unwrap request: Put https://10.244.0.25:8200/v1/sys/wrapping/unwrap: x509: certificate is valid for 127.0.0.1, not 10.244.0.25” timestamp=2022-09-23T11:53:44.843Z

  config: |
    plugin_directory = "/usr/local/libexec/vault"
    ui = true
    listener "tcp" {
      address = "[::]:8200"
      cluster_address = "[::]:8201"
      tls_disable = false
      tls_cert_file = "/vault/userconfig/vault-server-tls/tls.crt"
      tls_key_file  = "/vault/userconfig/vault-server-tls/tls.key"
    }
    # Advertise the non-loopback interface
    api_addr = "[::]:8200"
    cluster_addr = "[::]:8201"
    storage "file" {
      path = "/vault/data"
    }

This is indeed a fairly complex one to understand, unless you’ve read a couple of specific areas in the Vault source code!

Somewhat surprisingly, when Vault starts up a plugin, the initial negotiation of the communications channel between Vault and the plugin, requires the plugin to make an HTTP request to the api_addr of the Vault server!

This is what is failing here.

You have set the api_addr in the configuration to the all-zeros address. Vault has responded to this by updating it to a specific IP address for the host, since the all-zeros address cannot be directly connected to.

The TLS certificate you are using does not contain an IP address Subject Alternative Name for this IP address, so when the plugin comes to attempt to make this request, the TLS negotiation fails.

To remedy this, you could:

  1. Arrange for your TLS certificate to contain an appropriate IP SAN.
  2. Change your api_addr to include a hostname, and include that hostname in your TLS certificate.

Thanks for your answer! Can you please explain what is IP SAN. I use cert-manager to generate the vault certificate which contains the following:

spec:
dnsNames:
- vault
- vault.fybrik-system
- vault.fybrik-system.svc
- vault.fybrik-system.svc.cluster.local
ipAddresses:
- 127.0.0.1

what should I change in the vault configuration given the above certificate? Thanks

An IP Address Subject Alternative Name. Like the 127.0.0.1 that you have already got in your certificate.

However, since you’ve now revealed you’re in Kubernetes, using an IP address isn’t going to work, since it will change whenever the pod is rescheduled.

api_addr = "https://vault.fybrik-system.svc.cluster.local:8200"

Unfortunately, I still get the same x509: certificate is valid for 127.0.0.1, not 10.244.1.53 error. This is what I used: Thanks

  config: |
    plugin_directory = "/usr/local/libexec/vault"
    ui = true
    listener "tcp" {
      address = "[::]:8200"
      cluster_address = "[::]:8201"
      tls_disable = false
      tls_cert_file = "/vault/userconfig/vault-server-tls/tls.crt"
      tls_key_file  = "/vault/userconfig/vault-server-tls/tls.key"
      tls_client_ca_file = "/vault/userconfig/vault-server-tls/ca.crt"

    }
    # Advertise the non-loopback interface
    api_addr = "https://vault.fybrik-system.svc.cluster.local:8200"
    cluster_addr =  "https://vault.fybrik-system.svc.cluster.local:8201"
    storage "file" {
      path = "/vault/data"
    }

plugin tls init: error="error during token unwrap request: Put https://10.244.1.54:8200/v1/sys/wrapping/unwrap: x509: certificate is valid for 127.0.0.1, not 10.244.1.54"

btw, I would also try also to run with mTLS and to do that I used: tls_require_and_verify_client_cert = true option . however, then I get another error which seems to be not related to the plugin: http: TLS handshake error from 127.0.0.1:39212: tls: client didn't provide a certificate

You have not said how you are deploying Vault to Kubernetes… but if you are using the HashiCorp Vault helm chart, it sets an environment variable, making whatever you write in your config file be ignored:

So you should remove the ignored setting from your config, and set it via Helm values instead.

Thanks!!! that seems to work. I am using standalone mode so I had to redefine VAULT_API_ADDR as follows:

extraEnvironmentVars:
  VAULT_API_ADDR: "https://vault.fybrik-system.svc.cluster.local:8200"

btw I see this warning now:

W1031 14:58:51.770702 1275809 warnings.go:70] spec.template.spec.containers[0].env[12].name: duplicate name “VAULT_API_ADDR”

Thanks again for your help! I appreciate your help in configuring mutual tls. I used the following settings (adding tls_require_and_verify_client_cert to the above settings) and I get http: TLS handshake error from 127.0.0.1:59792: tls: client didn't provide a certificate error Thanks again!

server:
standalone:
config: |
plugin_directory = “/usr/local/libexec/vault”
ui = true
listener “tcp” {
address = “[::]:8200”
cluster_address = “[::]:8201”
tls_disable = false
tls_cert_file = “/vault/userconfig/vault-server-tls/tls.crt”
tls_key_file = “/vault/userconfig/vault-server-tls/tls.key”
tls_client_ca_file = “/vault/userconfig/vault-server-tls/ca.crt”
tls_require_and_verify_client_cert = true
}
# Advertise the non-loopback interface
storage “file” {
path = “/vault/data”
}
extraEnvironmentVars:
VAULT_API_ADDR: “https://vault.fybrik-system.svc.cluster.local:8200

Um… I’m really not sure if there will be any unforeseen consequences from defining a variable in

that is already defined elsewhere in the template.

You really ought to set it the way the Helm chart intends it to be set:

Not doing this is the cause of the warning:

OK thanks will try to use ha instead of standalone.
IIUC in k8s vault with tls will work only with ha? is there a documentation how to configure vault tls in k8s?
I used Standalone Server with TLS | Vault | HashiCorp Developer as a guide but it seems to not work on k8s. Thanks again

Oh… I can see how the naming of the Helm value could cause confusion.

Despite having ha in its name, it’s equally applicable to standalone mode.

The Vault helm chart is unfortunately quite confusing in some ways.

Thanks again for your help!!! The following configuration which enables mutual tls finally worked for me:

 server:
   ha:
     enabled: true
     replicas: 1

  # Set the api_addr configuration for Vault HA
  # See https://www.vaultproject.io/docs/configuration#api_addr
  # If set to null, this will be set to the Pod IP Address
  apiAddr: "https://vault.fybrik-system.svc.cluster.local:8200"

  # Set the cluster_addr confuguration for Vault HA
  # See https://www.vaultproject.io/docs/configuration#cluster_addr
  # If set to null, this will be set to https://$(HOSTNAME).{{ template "vault.fullname" . }}-internal:8201
  clusterAddr: "https://vault.fybrik-system.svc.cluster.local:8201"

  config: |
    plugin_directory = "/usr/local/libexec/vault"
    ui = true
    listener "tcp" {
      address = "[::]:8200"
      cluster_address = "[::]:8201"
      tls_disable = false
      tls_cert_file = "/vault/userconfig/vault-server-tls/tls.crt"
      tls_key_file  = "/vault/userconfig/vault-server-tls/tls.key"
      tls_client_ca_file = "/vault/userconfig/vault-server-tls/ca.crt"
      tls_require_and_verify_client_cert = true
    }
    storage "file" {
      path = "/vault/data"
    }
    disable_mlock = true

Another question: what the difference between tls_disable_client_certsand tls_require_and_verify_client_cert
Many thanks!

You really shouldn’t set this… You won’t notice whilst using just one replica, but this setting needs to route traffic to individual nodes.

Pretty much exactly what the names say…

1 Like