Kubernetes Ingress-Controller and AWS API Gateway client certificate

9/14/2018

I have an issue, I want to use an API Gateway client certificate with my ingress config.

  1. I've generated the certificate on AWS.
  2. I've created the secret of thi certificate:

    kubectl create secret generic api --from-file=api-gateway-client-certificate.crt 
    --namespace develop
    
  3. I've added the configuration on my ingress file:

    annotations:
    nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
    nginx.ingress.kubernetes.io/auth-tls-secret: "default/api"
    nginx.ingress.kubernetes.io/auth-tls-verify-depth: "1"`

Finally I don't know why I get this error on the ingress-controller:

Error obtaining X.509 certificate: Secret "develop/api" contains no keypair or CA certificate

I use Kubernetes v1.11.1 and nginx-ingress-controller v0.17.1

-- Dedsec Samy
amazon-web-services
api-gateway
aws-api-gateway
kubernetes
nginx

3 Answers

9/17/2018

Yes you are right i don't have the private key, I use the client certificate from API Gateway and it dosen't give me access to the key I just have the CA.

I tried to add the private key from my domain CA but the private key doesn't match public key https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html#certificate-validation

I don't know how i can add the API Gateway client certificate.

-- Dedsec Samy
Source: StackOverflow

11/14/2019

Had the same error, it's because of a bad naming of the ca file.

Use this to create your secret:

kubectl create secret generic api --from-file=ca.crt=api-gateway-client-certificate.crt --namespace develop
-- Yuval
Source: StackOverflow

9/14/2018

So you are missing the key and/or the CA for your cert. Did you use a private CA in AWS? The regular certificate manage doesn't give you a key file because it creates the CSR under the hood.

Generally, you'd create your tls secret like this:

kubectl -n kube-system create secret tls my-tls-cert --key=tls.key --cert=tls.crt

Also, I would append the CA that begins to with -----BEGIN CERTIFICATE----- to the content of api-gateway-client-certificate.crt

-- Rico
Source: StackOverflow