Skip to content
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

cert-sync does not work with a cert issued by integrate CA #155

Open
endapril opened this issue Feb 18, 2021 · 11 comments
Open

cert-sync does not work with a cert issued by integrate CA #155

endapril opened this issue Feb 18, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@endapril
Copy link

When I try to use sync Certificate from Azure Keyvault. If the cert is self-signed cert, it works properly as expected.
But when I try syncing a certificate which Authority is an integrated CA(Microsoft OneCertV2-PublicCA in my case), it did generate a tls secret, but the cert does not contain right serial number or correct issuer.

Could you please help?

@endapril
Copy link
Author

endapril commented Feb 18, 2021

Below is the cert i am trying to sync
image

And this is my cert-sync yaml
apiVersion: spv.no/v1
kind: AzureKeyVaultSecret
metadata:
name: cert-sync
namespace: default
spec:
vault:
name: rduimiddlewaretestkv
object:
name: middleware-ppe-ssl-cert
type: certificate
output:
secret:
name: middleware-ppe-ssl-cert
type: kubernetes.io/tls

@torresdal
Copy link
Collaborator

Hmmm... Must admit we haven't tested this with integrated CA and don't have one available. Are the any errors you can see from the Controller log, which might help us to know what's going on?

@kristeey kristeey added the bug Something isn't working label Aug 26, 2021
@kbujanecki-dt
Copy link

Same issue with Let's Encrypt
Log from nginx ingress controller
W0826 13:53:50.695301 6 backend_ssl.go:46] Error obtaining X.509 certificate: unexpected error creating SSL Cert: certificate and private key does not have a matching public key: tls: private key does not match public key

@caseyzhang123
Copy link

Same issue here:

Created an ssl cert in key vault using the Microsoft OneCertV2-PublicCA
w4-cl-sync-test-ssl-cert

However, the cert synced to kubernetes is what seems to be the Digicert root certificate
Digicert

It is preventing us from using akv2k8s as we cannot get the right ssl cert synced, and thus cannot properly set up tls.

@pavel-sha
Copy link

Yes, my situation is similar. A truly self-signed certificate works, but Azure wildcard certificate for a domain does not work that way. Created a wildcard certificate in openwork. Synchronized with the key vault, a secret is automatically created there. All checkboxes are green, everything is ok! This secret is created in aks in the corresponding namespace in a secret like kubernetes.io/tls (using akv2k8s). Synchronization occurs, everything is ok. Crt and key I see. I attach this secret to the ingress in the rules and tls section to the host (hostname with the appropriate name for the domain) and writes that fake Certificate and substitutes the default “Acme Co, Kubernetes Ingress Controller Fake Certificate”, in the ingress logs “Error getting Ssl certificate, local ssl certificate not found. Using default certificate. “What should I do? Why does not it work?

@KrzychuR
Copy link

Same case as described by @pavel-sha , I was hoping to use this tool :(

@jerry-santana
Copy link

I faced the same issue with Azure KeyVault and OneCertV2-PublicCA.

Honestly, didn't want to spend a lot of time on this and I ended up just doing the classic approach which is very simple:

  1. Download PFX from KeyVault
  2. Generate CRT
  3. Generate KEY
  4. Create AKS Secret of type kubernetes.io/tls
  5. Use that secret in the Ingress yaml

I know this is not fixing the original issue with akv2k8s but it's an alternative which only takes 1 minute to complete.

I hope it helps.

@KrzychuR
Copy link

KrzychuR commented May 22, 2023

@jerry-santana I've decided to just create a script using Azure CLI to automate steps as you mentioned above. Then we have simple scheduler once per day to sync K8s secrets with KeyVault certs. Quite simple, there is no need to use any complex solutions (if you want to just sync certificates).

@jerry-santana
Copy link

@KrzychuR I tried to do the same but unfortunately it didn't work.

Did you use Workload identity to authenticate keyvault? or it was Pod identity?

@KrzychuR
Copy link

@jerry-santana Azure DevOps pipeline (just like regular build) running script so everything is in place: KeyVault authentication and also access to AKS.

@venkat-microsoft
Copy link

https://akv2k8s.io/reference/azure-key-vault-secret/#chain-order solves the issue with Microsoft OneCertV2-PublicCA certs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants