runtime: Exception of type 'Interop+AndroidCrypto+SslException' was thrown in .NET MAUI 8.0 preview
Description
Exception of type ‘Interop+AndroidCrypto+SslException’ was thrown when my android emulator try to connect my simulator device running in my computer. wireshark throws Alert (Level: Fatal, Description: Protocol Version) after server hello done. I have attached the screenshot. I set TLSV 1.2 during sslsteam connection but I still see Tls 1.0 in wireshark in client hello.
Code:
try
{
// Set SSL/TLS protocol version for Android
TcpClient client1 = new TcpClient(ipaddress, 443);
Console.WriteLine("Client connected.");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
SslStream abcd = new SslStream(client1.GetStream(), false, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback, EncryptionPolicy.RequireEncryption);
string name = abcd.TargetHostName;
var sslclient = new SslClientAuthenticationOptions()
{
TargetHost = "Device",
LocalCertificateSelectionCallback = LocalCertificateSelectionCallback,
RemoteCertificateValidationCallback = RemoteCertificateValidationCallback,
EnabledSslProtocols = SslProtocols.Tls12,
AllowRenegotiation = false,
};
abcd.AuthenticateAsClient(sslclient);
bool succ = abcd.IsMutuallyAuthenticated;
abcd.Close();
client.Close();
}
catch (AuthenticationException e)
{
Console.WriteLine("Exception: {0}", e.Message);
if (e.InnerException != null)
{
Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
}
Console.WriteLine("Authentication failed - closing the connection.");
client.Close();
connectSuccessfull = callbackmessage + "AuthenticationFailed " + e.Message;
return connectSuccessfull;
}
Steps to Reproduce
try
{
// Set SSL/TLS protocol version for Android
TcpClient client1 = new TcpClient(ipaddress, 443);
Console.WriteLine("Client connected.");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
SslStream abcd = new SslStream(client1.GetStream(), false, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback, EncryptionPolicy.RequireEncryption);
string name = abcd.TargetHostName;
var sslclient = new SslClientAuthenticationOptions()
{
TargetHost = "Device",
LocalCertificateSelectionCallback = LocalCertificateSelectionCallback,
RemoteCertificateValidationCallback = RemoteCertificateValidationCallback,
EnabledSslProtocols = SslProtocols.Tls12,
AllowRenegotiation = false,
};
abcd.AuthenticateAsClient(sslclient);
bool succ = abcd.IsMutuallyAuthenticated;
abcd.Close();
client.Close();
}
catch (AuthenticationException e)
{
Console.WriteLine("Exception: {0}", e.Message);
if (e.InnerException != null)
{
Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
}
Console.WriteLine("Authentication failed - closing the connection.");
client.Close();
connectSuccessfull = callbackmessage + "AuthenticationFailed " + e.Message;
return connectSuccessfull;
}
Link to public reproduction project repository
eererr
Version with bug
8.0.0-preview.3.8149
Last version that worked well
Affected platforms
Android
Affected platform versions
Android 12
Did you find any workaround?
No I did not find any workaround yet. Need urgent help
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 15 (12 by maintainers)
@simonrozsival please take a look when you have a moment.