SSlStream Authentication failing in .NET MAUI Android app whereas same is working in Xamarin.forms

Venkatareddy Desireddy 0 Reputation points
2024-11-05T11:11:23.7066667+00:00

have connected to Controller via WiFi from .NET MAUI Android app and TLS is enabled in connected Controller.

From .NET MAUI Android project, I am trying to authenticate SSLStream with below code SslStream _secureStream = new SslStream( new TcpClient().GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null); _secureStream.AuthenticateAsClient(serverName); //serverName is certificate name here

While authenticating it is throwing exception as below {System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Interop+AndroidCrypto+SslException: Exception of type 'Interop+AndroidCrypto+SslException' was thrown. at Interop.AndroidCrypto.SSLStreamSetTargetHost(SafeSslHandle sslHandle, String targetHost) at System.Net.SafeDeleteSslContext.InitializeSslContext(SafeSslHandle handle, SslAuthenticationOptions authOptions) at System.Net.SafeDeleteSslContext..ctor(SslAuthenticationOptions authOptions) at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteSslContext& context, ReadOnlySpan1 inputBuffer, Byte[]& outputBuffer, SslAuthenticationOptions sslAuthenticationOptions) --- End of inner exception stack trace --- at System.Net.Security.SslStream.<ForceAuthenticationAsync>d__1501[[System.Net.Security.SyncReadWriteAdapter, System.Net.Security, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions) at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost)

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,587 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.