4

Hello i'm a new user of ubuntu (installed version 22.04) and i have problems with it from the start... Currently i am struggling with running integration tests with Jetbrains Rider (I run the application without any problems and connect to this database).

The error that i have is:

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
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at System.Net.Security.SslStream.ProcessAuthentication(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken)
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)
at System.Data.SqlClient.SNI.SNITCPHandle.EnableSsl(UInt32 options)

System.TypeInitializationException
The type initializer for 'SslMethods' threw an exception.
at Interop.OpenSsl.AllocateSslContext(SslProtocols protocols, SafeX509Handle certHandle, SafeEvpPKeyHandle certKeyHandle, EncryptionPolicy policy, SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SafeDeleteSslContext..ctor(SafeFreeSslCredentials credential, SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteSslContext& context, ReadOnlySpan`1 inputBuffer, Byte[]& outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)

System.TypeInitializationException
The type initializer for 'Ssl' threw an exception.
at Interop.Ssl.SslV2_3Method()
at Interop.Ssl.SslMethods..cctor()

System.TypeInitializationException
The type initializer for 'SslInitializer' threw an exception.
at Interop.Ssl..cctor()

Interop+Crypto+OpenSslCryptographicException
error:0E076071:configuration file routines:MODULE_RUN:unknown module name
at Interop.SslInitializer..cctor()

Ubuntu 22.04, .dotnet 5.0.213, Rider 2022.1

Anyone encountered such a problem?

2
  • Looks like a certificate issue, maybe you're not trusting your server's certificate
    – mu88
    Apr 26, 2022 at 12:48
  • well maybe, but its weird coz i can connect by app or Rider database explorer so why i cant by tests?
    – Szpur
    Apr 27, 2022 at 6:42

2 Answers 2

19

This is probably due to the OpenSSL config. I had a simlar problem and resolved it with this command:

sed -i 's/openssl_conf = openssl_init/#openssl_conf = openssl_init/g' /etc/ssl/openssl.cnf 

See Commit on github and Github issue

for more details.

6
  • Wow that's it! It totally helps, thank you very much! It is my first time with ubuntu so i can't figure it out by myself :D
    – Szpur
    May 7, 2022 at 15:45
  • Connecting to MSSQL in Ubuntu 22.04 and this solved the issue, thanks Jun 28, 2022 at 9:00
  • Do I have to restart a service afterwards? Jul 5, 2022 at 17:48
  • Not that I can recall. You just need to reconnect to the database. This file is read by the JavaVM on demand.
    – dpnmn
    Aug 1, 2022 at 12:25
  • Pretty strange problem, with efcore it was working, instead with Npgsql directly is was firing the error... Does anybody knows if this is originated by rider build or something else? Inside a docker container i didn't find any issue. Jan 27 at 9:48
0

you can try to add to your connection string: Encrypt=False;TrustServerCertificate=True". Of course, that is an only a temporary solution and that can be made only for tests.

1
  • 1
    I tried to use this in connection string but sadly, it didnt help :(
    – Szpur
    May 4, 2022 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.