This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.6k
stars
2.82k
forks
source link
azure-identity | CertificateCredential fails to parse PEM certificate (Error "Failed to deserialize certificate in PEM or PKCS12 format") #38263
Describe the bug
Getting 'Failed to deserialize certificate in PEM or PKCS12 format' error while using 'CertificateCredential' python module in 'azure.identity' python package.
Also tried passing the certificate as bytes. I have some degree of confidence that it's not the certificate causing the issue. I did get this to work by manually uploading the certificate via Kudu, but ideally, I would like to use Key Vault or even directly through the Function App using azure portal.
Reference the Key Vault certificate in a function app through azure portal (have not tried to upload directly without Key Vault) and set the variable WEBSITE_LOAD_CERTIFICATES to the certificate thumbprint.
Reference the cert path in code in the any basic function app. This fails and does not create the credentials.
from azure.identity import CertificateCredential
Expected behavior
The credential should be created and would move on to get the API token. Instead it fails.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
a similar issue on GitHub that was marked as "resolved" back in 2022. However, if you read further in the comments, you will see that others are still facing this issue even after it was marked as resolved. https://github.com/Azure/azure-sdk-for-python/issues/24643
Describe the bug Getting 'Failed to deserialize certificate in PEM or PKCS12 format' error while using 'CertificateCredential' python module in 'azure.identity' python package.
Also tried passing the certificate as bytes. I have some degree of confidence that it's not the certificate causing the issue. I did get this to work by manually uploading the certificate via Kudu, but ideally, I would like to use Key Vault or even directly through the Function App using azure portal.
https://learn.microsoft.com/en-us/azure/app-service/configure-ssl-certificate-in-code?tabs=linux https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.certificatecredential?view=azure-python#examples
To Reproduce Steps to reproduce the behavior:
Reference the cert path in code in the any basic function app. This fails and does not create the credentials.
from azure.identity import CertificateCredential
credential = CertificateCredential( tenant_id="",
client_id="",
certificate_path="/var/ssl/private/.p12",
password="",
)
Expected behavior The credential should be created and would move on to get the API token. Instead it fails.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context a similar issue on GitHub that was marked as "resolved" back in 2022. However, if you read further in the comments, you will see that others are still facing this issue even after it was marked as resolved. https://github.com/Azure/azure-sdk-for-python/issues/24643