ServiceRequestError: SSL Certificate Verification Failure with Azure Document Intelligence

Nirmalsing Patil 20 Reputation points
2024-06-09T22:42:47.6666667+00:00

I am encountering a ServiceRequestError when attempting to analyze a PDF document using the Azure Document Intelligence service. The error seems to be related to SSL certificate verification. Below is the full traceback for your reference:

ServiceRequestError Traceback (most recent call last)

...

ServiceRequestError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)


def get_text_from_pdf(fname):
    #try:
        fstream = open(fname, "rb")
        inputpdf = PdfReader(fstream)
        page_dict = {}

        document_intelligence_client = DocumentIntelligenceClient(endpoint=config['doc_intel_endpoint'],
                                                                  credential=AzureKeyCredential(config['doc_intel_key']),pipeline=pipeline)
        for i in range(len(inputpdf.pages)):
            output = PdfWriter()
            output.add_page(inputpdf.pages[i])
            response_bytes_stream = BytesIO()
            output.write(response_bytes_stream)

            poller = document_intelligence_client.begin_analyze_document(
                "prebuilt-layout",
                AnalyzeDocumentRequest(bytes_source=response_bytes_stream.getvalue()),
                output_content_format=ContentFormat.MARKDOWN
            )
            result: AnalyzeResult = poller.result()
            page_dict[i + 1] = result.content

        fstream.close()
        return page_dict
    # except Exception as e

Environment Details:

  • SDK Version:
      azure-ai-documentintelligence==1.0.0b3
      azure-ai-ml==1.15.0
      azure-common==1.1.28
      azure-core==1.30.1
      azure-identity==1.16.0
      azure-mgmt-core==1.4.0
      azure-search-documents==11.4.0
      azure-storage-blob==12.19.1
      azure-storage-file-datalake==12.14.0
      azure-storage-file-share==12.15.0
      azure-search-documents==11.4.0
    
  • Python Version: 3.10.4
  • Operating System: Windows 10

Steps to Reproduce:

  1. Install the required libraries using pip install azure-ai-documentintelligence pypdf2.
  2. Run the provided code snippet with the given PDF file path.
  3. Observe the ServiceRequestError during the document analysis process.

Request:

Could you please assist in resolving this SSL certificate verification issue? It appears that there might be a problem with the SSL certificate chain used by the Azure Document Intelligence service.

Thank you for your support.

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,504 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,576 questions
{count} votes

Accepted answer
  1. navba-MSFT 19,655 Reputation points Microsoft Employee
    2024-06-12T02:13:07.6533333+00:00

    @Nirmalsing Patil I'm glad to see you were able to identify the solution for this issue. Thanks 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:

    You are encountering the below ServiceRequestError when attempting to analyze a PDF document using the Azure Document Intelligence service.

    ServiceRequestError Traceback (most recent call last)

    ...

    ServiceRequestError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)

    .

    .

    Resolution:

    You confirmed with Azure-sdk-team that by adding connection_verify=False when you create the client will help to disable the ssl verification. https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md#configurations

    0 comments No comments

0 additional answers

Sort by: Most helpful