Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[ODBC SQL Server Driver][DBNETLIB]SSL Security error (18)

I'm trying to connect to a SQL Server using pyodbc 4.0.30 with Python 3.7. Everything was going great the past couple of days until today when I get this error:

OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error (18) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (SECCreateCredentials()). (1)')`

My connection:

conn = pyodbc.connect('driver={SQL Server};server=redacted;database=uipcc_awdb;uid=redacted;pwd=redacted;trusted_connection=no;')

Please note I can connect normally to the database via SQL Server Management Studio, and no changes were made on my machine, the SQL Server, or the network.

I need to emphasize, I have tried to following which were mentioned in similar questions (but none worked):

  • adding sslverify=0 in the connection parameters
  • adding encrypt=0 in the connection parameters
  • Changing the OBDC drivers from my machine, didn't work and ruined the connection from SQL Server Management Studio
like image 731
YoZo Avatar asked Sep 06 '25 15:09

YoZo


2 Answers

Try enabling TLS 1.0 on your registry at this location:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS1.0\Client\

For eg:

Change it to:

like image 188
Ash K Avatar answered Sep 08 '25 10:09

Ash K


This is most likely a TLS version issue. TLS 1.0/ TLS 1.1 has probably been disabled on the SQL Server.

There is currently an open issue on the pyodbc github tracker

And see this other question: Pyodbc giving exception with older version of sql driver but failing with latest version

like image 42
Henrik Høyer Avatar answered Sep 08 '25 12:09

Henrik Høyer