How to solve 'CERTIFICATE_VERIFY_FAILED' in azure function python using Azurite

Makoto Oda 291 Reputation points
2023-03-15T07:06:03.8133333+00:00

I've configured Azurite HTTPS Setup using mkcert.

I can connect to Azurite from Azure Storage Explorer.

However, I cannot connect to Azurite from Azure Function (Python).

I refer to azure.storage.blob.BlobClient, and the error message is as follows:

(omission)

.venv\lib\site-packages\azure\core\pipeline\_base.py:100: in send
    self._sender.send(request.http_request, **request.context.options),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <azure.core.pipeline.transport._requests_basic.RequestsTransport object at 0x000001AE43B7C460>
request = <HttpRequest [PUT], url: 'https://127.0.0.1:10000/devstoreaccount/{container_name}/{blob_relative_path}'>
kwargs = {'stream': False}, response = None
error = ServiceRequestError('[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')
connection_timeout = 20, timeout = (20, 80000), read_timeout = 80000

(omission)

The same code works without HTTPS setup.

How do I solve this error?

Azure Storage Explorer
Azure Storage Explorer
An Azure tool that is used to manage cloud storage resources on Windows, macOS, and Linux.
233 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,473 questions
{count} votes

Accepted answer
  1. SaiKishor-MSFT 17,206 Reputation points
    2023-03-17T18:54:23.88+00:00

    @Makoto Oda I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    I've configured Azurite HTTPS Setup using mkcert.

    I can connect to Azurite from Azure Storage Explorer.

    However, I cannot connect to Azurite from Azure Function (Python).

    I refer to azure.storage.blob.BlobClient, and the error message is as follows:

    error = ServiceRequestError('[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)'

    The same code works without HTTPS setup.

    Solution:

    I further searched, and I found this issue.

    When I set %USERPROFILE%\AppData\Local\mkcert\rootCA.pem to the environment variable REQUESTS_CA_BUNDLE, I could solve CERTIFICATE_VERIFY_FAILED error.


    Please let us know if you have any more questions and we will be glad to assist you further. Thank you!

    Remember:

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    Want a reminder to come back and check responses? Here is how to subscribe to a notification.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Tyler Suard 55 Reputation points
    2023-10-30T16:39:01.6033333+00:00

    Running set REQUESTS_CA_BUNDLE=REQUESTS_CA_BUNDLE did not work for me. I am still having the same issue with connecting to azure storage from my local computer using VScode. Any help with solving this issue would be greatly appreciated.

    1 person found this answer helpful.