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

ClientSecretCredential.get_token failed: Authentication failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997) #35519

Open
takkouet opened this issue May 7, 2024 · 7 comments
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@takkouet
Copy link

takkouet commented May 7, 2024

I'm using the azusre SDK to retrieve secrets from key vault.

from azure.identity import ClientSecretCredential
from azure.keyvault.secrets import SecretClient
from dotenv import load_dotenv
import os

load_dotenv()
TENANT_ID = os.getenv("AZURE_TENANT_ID")
CLIENT_ID = os.getenv("AZURE_CLIENT_ID")
CLIENT_SECRET = os.getenv("AZURE_CLIENT_SECRET")


class AzureKeyVault:
    def __init__(self, vault_name: str):
        self.vault_url = f"https://{vault_name}.vault.azure.net/"

    def __auth(self):
        try:
            credential = ClientSecretCredential(
                tenant_id = TENANT_ID,
                client_id = CLIENT_ID,
                client_secret = CLIENT_SECRET,
                # connection_verify=False # Only in dev, investigating for furthere stable solution
            )
            client = SecretClient(vault_url=self.vault_url, credential=credential)
            return client
        except Exception as e:
            error_message = f"Couldn't authenticate key vault {self.vault_url}, due to:\n {e}"
            raise Exception(error_message)

    def GetSecret(self, secret_name: str, secret_version: str = None) -> str:
        try:
            client = self.__auth()
            secret = client.get_secret(secret_name, secret_version).value
            return secret
        except Exception as e:
            error_message = f"Couldn't retrieve secret {secret_name} from {self.vault_url}, due to:\n {e}"
            raise Exception(error_message)

print(AzureKeyVault("key-vault-XXXXXXXX").GetSecret("admin-username"))
>> pqvinh2 (This was returned when uncomment connection_verify = False)
>> ClientSecretCredential.get_token failed: Authentication failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997) (This was returned when comment connection_verify = False)

As you can see if i uncomment connection_verify = False when declaring credential, it works perfectly fine. I also use this script on my PC at work and no issue was to be found, but it keeps telling me that my cert is expired when I tried to run the script on my PC at home.

Please help me to identify and resolve this problem. Thank you!

@github-actions github-actions bot added Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels May 7, 2024
Copy link

github-actions bot commented May 7, 2024

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@xiangyan99
Copy link
Member

Thanks for reaching out.

It looks to me there might be something wrong in your environment. e.g. did you set certificate on your home machine?

I cannot repro the issue on my machine.

@xiangyan99 xiangyan99 added the needs-author-feedback More information is needed from author to address the issue. label May 7, 2024
@github-actions github-actions bot removed the needs-team-attention This issue needs attention from Azure service team or SDK team label May 7, 2024
Copy link

github-actions bot commented May 7, 2024

Hi @takkouet. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@takkouet
Copy link
Author

takkouet commented May 7, 2024

Thanks for reaching out.

It looks to me there might be something wrong in your environment. e.g. did you set certificate on your home machine?

I cannot repro the issue on my machine.

Hi Xiangyan,
Sorry I'm quite vague about this security thing. Below are all the certs on my home PC. Can I ask which specific kind of certificate may cause the issue I'm raising?
image

@github-actions github-actions bot added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels May 7, 2024
@pvaneck
Copy link
Member

pvaneck commented May 12, 2024

On your home computer, try running pip install --upgrade certifi in your Python environment to see if that resolves the cert error.

@xiangyan99 xiangyan99 added the needs-author-feedback More information is needed from author to address the issue. label May 14, 2024
Copy link

Hi @takkouet. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions github-actions bot removed the needs-team-attention This issue needs attention from Azure service team or SDK team label May 14, 2024
Copy link

Hi @takkouet, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Status: Untriaged
Development

No branches or pull requests

3 participants