Hello Shel, S,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you SSL connection could not be established with Azure Document Intelligence for .NET CORE.
Regarding your question:
I see that there is a solution for python where one can specify connection_verify=False Is there a similar one for .NET core?
Yes, in .NET Core, you can achieve the equivalent of connection_verify=False
(used in Python) by disabling SSL certificate validation. By creating an HttpClientHandler
that ignores SSL certificate errors and use it with DocumentIntelligenceClient
:
using System;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using Azure;
using Azure.AI.DocumentIntelligence;
using Azure.Core.Pipeline;
// Create an HttpClientHandler that ignores SSL certificate validation
HttpClientHandler httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, certificate, chain, sslPolicyErrors) => true
};
// Create an HttpClient using the handler
HttpClient httpClient = new HttpClient(httpClientHandler);
// Use the HttpClient in DocumentIntelligenceClient
var clientOptions = new DocumentIntelligenceClientOptions
{
Transport = new HttpClientTransport(httpClient)
};
var client = new DocumentIntelligenceClient(new Uri("<your-endpoint>"), new AzureKeyCredential("<your-api-key>"), clientOptions);
Warning: This disables SSL validation, making the connection insecure. Use it only for debugging! NOT for production environment.
Alternatively, if the SSL issue is due to outdated TLS settings, you can force the correct TLS version:
using System.Net;
using System.Net.Http;
// Set TLS version explicitly
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
This ensures your application supports the latest TLS versions while keeping SSL validation enabled.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.