Skip to content

Vault issuer with Kubernetes auth: claim "iss" is invalid due to the use of default service account tokens #4144

@rumanzo

Description

@rumanzo

🚧 Update 29 July 2022 🚧 If you are seeing the message "claim iss is invalid", the workaround is to disable iss validation in Vault as explained in Problem 3: Incohenrent iss.

In Kubernetes v1.20+, kube-apiserver requires the flag --service-account-issuer to be an URI (see documentation).

When I deployed the Vault Issuer with Helm, I got the following error on vault login api:

claim "iss" is invalid

I found in (vault.go)[https://github.com/jetstack/cert-manager/blob/master/pkg/internal/vault/vault.go#L313-L315] that cert-manager sends the JWT token as is, but Vault expects a JWT with an issuer equal to the value of the flag --service-account-issuer.

For example, when kube-apiserver is running with the flag:

--service-account-issuer=https://kubernetes.default.svc.cluster.local

then the JWT token used by cert-manager in the Vault issuer should have a payload that looks like this:

{
    "iss": "https://kubernetes.default.svc.cluster.local"
}

Instead of this, the JWT token looks like this:

{
    "iss": "kubernetes/serviceaccount"
}

My current workaround is to disable JWT Issuer Validation on my PKI config in Vault.

Steps to reproduce the bug:
Use latest version of kubernetes
Define service-account-issuer in kube-apiserver config
Setup vault issuer with this doc
use latest vault and create pki with JWT Issuer Validation enabled
try to create vault issuer

Environment details::

  • Kubernetes version: v1.21.0
  • cert-manager version: v1.4.0
  • Install method: e.g. helm

/kind bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/vaultIndicates a PR directly modifies the Vault Issuer codekind/featureCategorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.priority/backlogHigher priority than priority/awaiting-more-evidence.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions