-
Notifications
You must be signed in to change notification settings - Fork 72
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
certificate_p12 without a password #32
Comments
@mkg2 I was having issues getting people to actually tell me if this was actually working on Azure or not. Guess it wasn't 😕 Would you be able to save the bundle to a local file, actually set a password on it and then try it, to see if it worked? If it does, I might just update the code so that it has a static password of "changeit" or something, just basically to satisfy that requirement and still communicate that we effectively don't set a password on the P12 file. |
It might not be related, but it would be good to validate before I create a new issue, but I found that the base64 encoded value in certificate_p12 was not valid. I had to add "==" to the end of it to get mine to work. And another time just a single "=" Which is a bit of a pain. I plan to do a bit more digging but might help you move forward.
A better workaround would be to use a local-exec provisioner to use openssl to recreate a pfx |
@JimPaine that's the padding on the base64 encoding, which is good to know. I'll make sure that's in as well. So did it actually work for you without a password? |
Yea I just mentioned as it looked like your error mentioned it could have been an issue with the data or the password. But I do have it working with an Azure function with no password. |
Just in case this issue is not related to the padding issue I have raised a new issue here along with my findings. #33 |
@JimPaine thanks! I've replied in that thread as well. |
I can confirm that it does not work with Azure WAF without password (padding or not). +1 for 'changeit'. |
Unfortunately, it is not working as expected. Point 1:I have tried to store the certificate_p12 to a local file and ended up with an invalid text file. Terraform coderesource "local_file" "pkcs12" {
content = "${acme_certificate.certificate.certificate_p12}=="
filename = "/tmp/Cert_direct.p12"
} Certificate verificationI am expecting a base64 encoded data file in linux but below file is in text format. $ file /tmp/Cert_direct.p12
Cert_direct.p12: ASCII text, with very long lines, with no line terminators
$ Verification with keytool not working as well. $ keytool -list -v -keystore /tmp/Cert_direct.p12 -storetype PKCS12
keytool error: java.io.IOException: toDerInputStream rejects tag type 77
java.io.IOException: toDerInputStream rejects tag type 77
at sun.security.util.DerValue.toDerInputStream(DerValue.java:881)
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1939)
at java.security.KeyStore.load(KeyStore.java:1445)
at sun.security.tools.keytool.Main.doCommands(Main.java:827)
at sun.security.tools.keytool.Main.run(Main.java:368)
at sun.security.tools.keytool.Main.main(Main.java:361) Point 2:I have uploaded 'certificate_p12' directlry to azure vault. Terraform coderesource "azurerm_key_vault_secret" "cert" {
name = "cert"
value = "${acme_certificate.certificate.certificate_p12}=="
key_vault_id = "${data.azurerm_key_vault.main.id}"
content_type = "application/x-pkcs12"
} Then I tried to download the file from azure web console as certificate.
Point 3:Only workaround so far is to create the pkcs12 bundle with local-exec. resource "local_file" "private_key_pem" {
content = "${acme_certificate.certificate.private_key_pem}"
filename = "/tmp/key.pem"
}
resource "local_file" "certificate_pem" {
content = "${acme_certificate.certificate.certificate_pem}"
filename = "/tmp/cert.pem"
}
resource "null_resource" "main" {
triggers {
build_number = "${timestamp()}"
}
provisioner "local-exec" {
command = "openssl pkcs12 -export -out /tmp/Cert.p12 -in /tmp/cert.pem -inkey /tmp/key.pem -passout pass:abcd"
}
} Cerificate verification$ file Cert.p12
Cert.p12: data
$ Verification with keytool $ keytool -list -v -keystore /tmp/Cert.p12 -storetype PKCS12
Enter keystore password:
Keystore type: PKCS12
Keystore provider: SunJSSE
Your keystore contains 1 entry
....
... |
@mkg2 @piizei I can confirm this is the case. Seeing that it not consistent across Azure resources, I think it would be better to create a new optional argument, something like "p12_certificate_password" which defaults to an empty string. If you both agree I am happy to make the changes and create a PR later today. Only seems fair @vancluever, seeing that it is Azure based issues :) |
Sorry @piizei, picking it up today, I had a few things come up that I needed to sort. Still waiting on #34 to be merged in as well, so it might be worth doing the work around as that will also workaround that issue as well. Work in progress is here if you want to build and run yourself |
Hey all, this has now been merged and should be going out for release early next week. Thanks @JimPaine for the PR! |
Hello,
I am trying to pass 'certificate_p12' attribute to azure web application firewall Resource. Looks like it is mandatory to have a password while adding ssl_certificate into azure WAF.
acme Resources
acme module output
Calling WAF Resource
WAF Resource
Error
Any advise or guidance would be greatly appreciated..
Thanks,
mkg
The text was updated successfully, but these errors were encountered: