1

I found the following similar SO answer that didn't fix my issue.

I have a 5.0 console app and the HttpClient is being configured manually instead of using the Refit extension factory method (both ways result in the error).

Console app config, previous attempt to use refit factory extension method. I believe the answer is here somewhere...I need to find a way to define the the Ssl protocol here.

  var builder = 
    new HostBuilder()
        //.ConfigureServices((hostContext, services) =>
        //{
        //  services.AddRefitClient<IIdentityApi>()
        //          .ConfigureHttpClient(c => c.BaseAddress = new Uri("https://localhost:20595"));
       //})
      .UseConsoleLifetime();

Here is that code:

  var httpClientHandler = new HttpClientHandler
  {
     // tried Tls11, Tls13, None
     SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
  };

 var httpClient = new HttpClient(httpClientHandler)
 {
    BaseAddress = new Uri("https://localhost:20595")
 };

 var identityApi = RestService.For<IIdentityApi>(httpClient);

Stacktrace:

  System.Net.Http.HttpRequestException
  HResult=0x80131620
  Message=The SSL connection could not be established, see inner exception.
  Source=System.Net.Http
  StackTrace:
  ...
  Inner Exception 1:
  IOException: Cannot determine the frame size or a corrupted frame was received.
Will Lopez
  • 2,089
  • 3
  • 40
  • 64
  • Were you able to understand what happened and how to fix it? – Lucas Aug 12 '21 at 20:27
  • 1
    Hi @Lucas! No I didn't, I went another route. – Will Lopez Aug 17 '21 at 14:12
  • @WillLopez would you kindly provide your solution or delete this post so that googlers like myself don't fall for this dead-end post as well? Thanks! – Justin Van Bibber Sep 20 '21 at 19:41
  • @JustinVanBibber Sorry but I will leave this question because it still needs an answer. My solution isn't valid as it does not pertain to the question so I won't post that as an answer - I couldn't use the library, issue was not resolved. Thanks! – Will Lopez Sep 21 '21 at 13:04

0 Answers0