I am getting below exception for database connection with MAUI android emulator. Can you please help us to resolve issue.
Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)'
My connection string:
connString = "Data Source=;Database=;User Id=;Password=***;Encrypt=True;TrustServerCertificate=True";
Exception:
- $exception {Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> Interop+AndroidCrypto+SslException: Exception of type 'Interop+AndroidCrypto+SslException' was thrown.
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.<ForceAuthenticationAsync>d__146`1[[System.Net.Security.SyncReadWriteAdapter, System.Net.Security, Version=7.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 Microsoft.Data.SqlClient.SNI.SNITCPHandle.EnableSsl(UInt32 options) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SNI\SNITcpHandle.cs:line 615
at ESCMSMauiApp.Views.GetScanData.GetHSHData(Int64 hologramnumber) in C:\Users\stanukula\source\repos\ESCMSMauiApp\ESCMSMauiApp\Views\GetScanData.cs:line 34
at ESCMSMauiApp.Views.HologramScan.GetHologramData() in C:\Users\stanukula\source\repos\ESCMSMauiApp\ESCMSMauiApp\Views\HologramScan.xaml.cs:line 37
at ESCMSMauiApp.Views.HologramScan.Button_Clicked(Object sender, EventArgs e) in C:\Users\stanukula\source\repos\ESCMSMauiApp\ESCMSMauiApp\Views\HologramScan.xaml.cs:line 56
at Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked() in D:\a\_work\1\s\src\Controls\src\Core\Button.cs:line 278
at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager) in D:\a\_work\1\s\src\Controls\src\Core\ButtonElement.cs:line 85
at Microsoft.Maui.Controls.Button.SendClicked() in D:\a\_work\1\s\src\Controls\src\Core\Button.cs:line 253
at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked() in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Button\Button.Impl.cs:line 24
at Microsoft.Maui.Handlers.ButtonHandler.OnClick(IButton button, View v) in D:\a\_work\1\s\src\Core\src\Handlers\Button\ButtonHandler.Android.cs:line 153
at Microsoft.Maui.Handlers.ButtonHandler.ButtonClickListener.OnClick(View v) in D:\a\_work\1\s\src\Core\src\Handlers\Button\ButtonHandler.Android.cs:line 174
at Android.Views.View.IOnClickListenerInvoker.n_OnClick_Landroid_view_View_(IntPtr jnienv, IntPtr native__this, IntPtr native_v) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Views.View.cs:line 2285
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 121
ClientConnectionId:7e615876-689c-4f43-b813-b6b9968c9a6b
Error Number:-2146893019,State:0,Class:20} Microsoft.Data.SqlClient.SqlException