Skip to content

TLS 1.3 - Authentication failed because the remote party sent a TLS alert: 'ProtocolVersion'. #28

@VivantSenior

Description

@VivantSenior

Environment

  • Home Assistant Version: 2023.1.6
  • HADotNet Library Version: compiled from the source (06cc98c)
  • Visual Studio Version: 17.4.4
  • API call or endpoint that is failing: authentication

Describe the Problem

My HA instance forces to use TLS 1.3 and I'm trying to use HASS.Agent which uses this library but during initial connection I got an error: The SSL connection could not be established, see inner exception.

Code Sample

ClientFactory.Initialize("https://my-home-assistant-url/", "AbCdEf0123456789...");
var configClient = ClientFactory.GetClient<ConfigClient>();
var config = await configClient.GetConfiguration(); //error

Exception logs:

System.Net.Http.HttpRequestException
  HResult=0x80131501
  Message=The SSL connection could not be established, see inner exception.
  Source=System.Net.Http
  Stack tracek:
   w System.Net.Http.ConnectHelper.<EstablishSslConnectionAsync>d__2.MoveNext()
   w System.Threading.Tasks.ValueTask`1.get_Result()
   w System.Net.Http.HttpConnectionPool.<ConnectAsync>d__98.MoveNext()
   w System.Threading.Tasks.ValueTask`1.get_Result()
   w System.Net.Http.HttpConnectionPool.<CreateHttp11ConnectionAsync>d__100.MoveNext()
   w System.Threading.Tasks.ValueTask`1.get_Result()
   w System.Net.Http.HttpConnectionPool.<AddHttp11ConnectionAsync>d__74.MoveNext()
   w System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.<WaitWithCancellationAsync>d__1.MoveNext()
   w System.Threading.Tasks.ValueTask`1.get_Result()
   w System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.<WaitForConnectionAsync>d__5.MoveNext()
   w System.Threading.Tasks.ValueTask`1.get_Result()
   w System.Net.Http.HttpConnectionPool.<SendWithVersionDetectionAndRetryAsync>d__84.MoveNext()
   w System.Threading.Tasks.ValueTask`1.get_Result()
   w System.Net.Http.RedirectHandler.<SendAsync>d__4.MoveNext()
   w System.Net.Http.HttpClient.<<SendAsync>g__Core|83_0>d.MoveNext()
   w HADotNet.Core.BaseClient.<Get>d__6`1.MoveNext() w C:\Users\user\Desktop\HADotNet-master\HADotNet.Core\BaseClient.cs:wiersz 38
   w HADotNet.Core.Clients.ConfigClient.<GetConfiguration>d__1.MoveNext() w C:\Users\user\Desktop\HADotNet-master\HADotNet.Core\Clients\ConfigClient.cs:wiersz 22
   w Program.<<Main>$>d__0.MoveNext() w C:\Users\user\Desktop\HADotNet-master\ConsoleApp1\Program.cs:wiersz 10

Inner Exception 1:
AuthenticationException: Authentication failed because the remote party sent a TLS alert: 'ProtocolVersion'.

Inner Exception 2:
Win32Exception: The message received was unexpected or badly formatted.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions