runtime: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed) Mac OSX High Sierra 10.13.5
In PowerShell I try to test an SQL connection from a Mac OSX 10.13.5. DotNet Core and PowerShell were installed through homebrew.
$sqlStr = 'Data Source=SERVER;Initial Catalog=DB;Integrated Security=False;User ID=USER;Password=PASSWORD;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;'
$sqlConn = New-Object System.Data.SqlClient.SqlConnection $sqlStr
$con = $sqlConn.Open()
And I get this error:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)
dotnet --version : 2.1.300 $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 26 (3 by maintainers)
I got this error last week following change of one of our application to upgrade dot net core 3.1. This quick fix was to change the connection string to add this configuration ;TrustServerCertificate=true
Look like default behavior has changed between 2.2 and 3.1
Hope that will help you
Hi @keeratsingh the same issue on the CentOS 7
sdk 2.1.302 net core 2.1.2
Was problem with nuget v3 but fix DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=false works.
And now
Retrying ‘FindPackagesByIdAsync’ for source ‘https://api.nuget.org/v3-flatcontainer/microsoft.visualstudio.web.codegeneration.design/index.json’. The SSL connection could not be established, see inner exception. error:2006D002:BIO routines:BIO_new_file:system lib Retrying ‘FindPackagesByIdAsync’ for source ‘https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.all/index.json’.
System.Data.SqlClient.SqlException : A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed) ---- Interop+Crypto+OpenSslCryptographicException : error:2006D002:BIO routines:BIO_new_file:system lib Stack Trace: at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
I was having this issue connecting to SQL running in a docker container via SQL Ops Studio on my laptop running Ubuntu 16.04 (logged as a bug here: - https://github.com/Microsoft/sqlopsstudio/issues/2150). It was resolved by running: -
sudo update-ca-certificates --freshHello, I am still having this issue on centos 7 with net core sdk 2.1.302:
os version
cat /etc/*-releasenet core version
dotnet --infosystemd service definition
cat /etc/systemd/system/myservice-dev.serviceif the user running the service is set to root then there is no exception thrown, with any other user this exception is thrown:
I am seeing the same issue running .NET Core 2.1.300.