Allow Custom httpClientHandler
See original GitHub issueContext
I deployed my own LLM models on Azure OpenAI, the endpoint is a self-signed.
Issues Description
When I sent complete request to my self-signed endpoint, semantic kernel will return an error message:
Error: The SSL connection could not be established, see inner exception.
I tried to trace the inner exception at debugging mode, got:
The remote certificate is invalid because of errors in the certificate chain: RevocationStatusUnKnown"
Related Code
internal OpenAIClientAbstract(ILogger? log = null, IDelegatingHandlerFactory? handlerFactory = null)
{
this.Log = log ?? this.Log;
this._handlerFactory = handlerFactory ?? new DefaultHttpRetryHandlerFactory();
this._httpClientHandler = new() { CheckCertificateRevocationList = true };
this._retryHandler = this._handlerFactory.Create(this.Log);
this._retryHandler.InnerHandler = this._httpClientHandler;
this.HTTPClient = new HttpClient(this._retryHandler);
this.HTTPClient.DefaultRequestHeaders.Add("User-Agent", HTTPUseragent);
}
this._httpClientHandler = new() { CheckCertificateRevocationList = true };
The default httpClientHandler is set to always check certificate RevocationList.
Feature Request
Allow pass customized httpClientHandler either from _handlerFactory or from kernelBuilder.
Issue Analytics
- State:
- Created 6 months ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Creating Custom HTTPClient Handlers
This class expedites the development process in accessing data from a Web API, and allows for customizing the client handlers when the need ......
Read more >HttpClientHandler Class (System.Net.Http)
Gets a writable dictionary (that is, a map) of custom properties for the HttpClient requests. The dictionary is initialized empty; you can insert...
Read more >c# - Adding handler to default http client in ASP.NET Core
Documentation states that you can only add handlers or configure the inner most handler to named or typed clients.
Read more >Fun with the HttpClient pipeline - Thomas Levesque's .NET Blog
See, HTTP message handlers can be used to add custom behavior to how requests and responses are processed. I'll give a few examples....
Read more >Mocking an HttpClient using an HttpClientHandler
It's very easy to test a class that has an HttpClient using a custom HttpClientHandler . This way you don't need to change...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think there is a workaround right now. I believe @SergeyMenshykh was looking at enabling similar with https://github.com/microsoft/semantic-kernel/pull/73 and could address this as part of that change potentially.
This is now possible – you can specify your own httpClient when instantiating adding the AI Connectors:
https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/Connectors/Connectors.AI.OpenAI/KernelConfigOpenAIExtensions.cs
For instance:
`IKernel kernel = Kernel.Builder .AddAzureTextCompletionService(“deploymentName”, “endpoint”, “apikey”, httpClient: myCustomHttpClient) .Build();