question

KiruthigaManivannan-7315 avatar image
0 Votes"
KiruthigaManivannan-7315 asked RobCaplan edited

Client certificates with typed HttpClient not working in .net 5 Linux container

Adding client certificates to a typed HttpClient works in .net 3.1 linux docker container but fails in .net 5. I see that there is a breaking change in .net 5 to use TLS 1.3 and restricted Ciphersuites, how can I override that in .net 5 with a typed HttpClient ? How can I use the SocketsHttpHandler.SslOptions with a typed HttpClient to specify a wider set of Ciphersuites.
This is a sample of my code

   services.AddHttpClient<ISwishpayService, SwishpayService>()
   .ConfigurePrimaryHttpMessageHandler<SwishpayHandler>();

    
     public class SwishpayHandler: HttpClientHandler
     {
         private readonly IConfiguration _config;
         private readonly ILogger<SwishpayHandler> _logger;
         public SwishpayHandler(IConfiguration config, ILogger<SwishpayHandler> logger)
         {
             _config = config;
             _logger = logger;
             SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13;
             ClientCertificateOptions = ClientCertificateOption.Manual;
         }
 ......

dotnet-csharpdotnet-runtimedotnet-ad
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers