-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Unexpected modification of Certificate Content during azurerm_key_vault_certificate Update-In-Place #24482
Comments
@slideroh Thanks for filing this issue! However, I think this behavior is expected by pull request #20627 . This PR modifies the terraform-provider-azurerm/internal/services/keyvault/key_vault_certificate_resource.go Lines 623 to 624 in f32f73c
|
Please keep in mind, that in After that "recreate a certificate" during change of In that case, it creates the certificate incorrectly and skips the whole chain - as a result, after downloading the certificate secret - as I wrote there is only 1 certificate, instead of 2 (in my case) Old one certs:
and
New one (after update-in-place):
|
@wuxu92 # CA certificates
openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -key ca.key -sha256 -days 30 -out ca.pem -subj "/C=US/ST=New York/L=Manhattan/O=XYZ Corporation/OU=Intermediate-Root-CA/CN=RootCACorporateGateway"
# Core - Cert
openssl genrsa -out core.key 4096
openssl req -new -key core.key -out core.csr -subj "/C=US/ST=New York/L=Manhattan/O=XYZ Corporation/OU=Enduser/CN=CorporateGateway"
cat <<EOF > core.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
IP.1 = 127.0.0.1
EOF
openssl x509 -req -in core.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out core.crt -days 30 -sha256 -extfile core.ext
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in core.key -out core.pkcs8.key
cat core.crt ca.pem core.pkcs8.key > core.pem After update-in-place and download the cert (az keyvault secret download --name test-cert -f afterchangesecret-cert.pem) Thanks |
Thank you for your understanding and for your help! I appreciate it very much
I'd like to emphasize that the issue we're facing is causing a significant problem for us. Specifically, our code relies on taking the last certificate, and with the current behavior, the last certificate is changed and missing the IntermediateCA, as illustrated in the examples provided earlier. I believe it's a critical issue that needs attention and might generate outage, because of lifetime_action change, which is even not shown in Terraform Plan, that this will change the content (remove the CA) Thank you again, if you need any help from our side to solve this issue (to test/generate more examples), please let us know too! |
Hi @wuxu92, are there any updates on this issue/bug? |
@slideroh submitted a PR as above. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Is there an existing issue for this?
Community Note
Terraform Version
1.6.1
AzureRM Provider Version
3.75.0
Affected Resource(s)/Data Source(s)
azurerm_key_vault_certificate
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
The
update-in-place
operation on theazurerm_key_vault_certificate
resource for "test-cert" was expected to occur without modifying the actual content of the certificate.Specifically, only the lifetime_action trigger (80->85) was to update as shown above.
Expected that changes would be limited to the lifetime_action trigger within the certificate policy.
Actual Behaviour
When performing an
update-in-place
on theazurerm_key_vault_certificate
resource the unexpected behavior is observed.Specifically, the content of the certificate undergoes changes that result in the removal of one certificate from the chain, and the private key is altered.
Consequently, after the update, the SSL certificate is rendered ineffective (without chain), leading to operational issues with the associated site.
Is the option to force recreate each time something change in this resource block?
Steps to Reproduce
az keyvault certificate download --name test-cert -f prechange-cert.pem
az keyvault secret download --name test-cert -f prechange-secret-cert.pem
terraform apply
az keyvault certificate download --name test-cert -f afterchange-cert.pem
az keyvault secret download --name test-cert -f afterchangesecret-cert.pem
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: