pyodbc operational error 08001 ssl security error
Question:
I am trying to connect to my database on MS SQL Server 2016 using pyodbc via the below python script from my laptop (on Windows 10) and planning to have the code deployed in a Linux RHEL 6.4 server.
conn=pyodbc.connect('Driver={SQL Server};'
'Server=DB_Instance;'
'Database=DB_Name;'
'UID=user_name;'
'PWD=password;'
'Trusted_Connection=no;');
At my laptop, SQL Server (version: 10.00.17763.01) and SQL Server Native Client 11.0 (version: 2011.110.7493.04) are already available.
While executing the python script from my laptop, I am getting the below error message.
pyodbc.operationalError: (‘08001’, ‘[08001] [Microsoft] [ODBC SQL Server Driver][DBNETLIB]SSL Security error (18) (SQLDriverConnect); [08001] [Microsoft] [ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (SECDoClientHandshake()). (772)’)
As per the organization standard, TLS 1.0 is disabled on the windows server where the SQL Server is installed in the network. Since I am accessing the database via python script, we cannot temporarily enable TLS 1.0. I am looking for a direction. Any help is greatly appreciated!!
Answers:
Gord Thompson pointed Guna in the right direction in the comments:
Can you try using ODBC Driver 17 for SQL Server and see if that works for you?
– Gord Thompson
Guna said that this worked:
I was facing different set of errors. While adding the port number in addition to the server name, the problem got resolved. The ODBC Driver name also needs to be updated. conn=pyodbc.connect(‘Driver={ODBC Driver 17 for SQL Server};’ ‘Server=DB_Instance,port;’ ‘Database=DB_Name;’ ‘UID=user_name;’ ‘PWD=password;’ ‘Trusted_Connection=no;’);
– Guna
Posting this as a community Wiki just so that any searchers can see quickly that it was answered.
PROBLEM: –
When trying to perform password change for MSSQL server, you get the following error message:-SSL Security error
SOLUTION: –
It’s likely an issue with the version of the SQL Native Client driver being used to establish the connection.
-
Please Download & install "ODBC Driver 13 for SQL Server" on the CPM servers.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=50420
Download 32 bit driver : x86msodbcsql.msi
-
Install as usual
-
Edit MSSQL Platforms to change the connection command from
Driver={SQL Server};Server=%ADDRESS%;Database=%DATABASE%;Uid=%USER%;Pwd=%LOGONPASSWORD%;
to
Driver={ODBC Driver 13 for SQL Server};Server=%ADDRESS%;Database=%DATABASE%;Uid=%USER%;Pwd=%LOGONPASSWORD%;
-
Restart the CPM service to pick up the platform changes & retest
I am trying to connect to my database on MS SQL Server 2016 using pyodbc via the below python script from my laptop (on Windows 10) and planning to have the code deployed in a Linux RHEL 6.4 server.
conn=pyodbc.connect('Driver={SQL Server};'
'Server=DB_Instance;'
'Database=DB_Name;'
'UID=user_name;'
'PWD=password;'
'Trusted_Connection=no;');
At my laptop, SQL Server (version: 10.00.17763.01) and SQL Server Native Client 11.0 (version: 2011.110.7493.04) are already available.
While executing the python script from my laptop, I am getting the below error message.
pyodbc.operationalError: (‘08001’, ‘[08001] [Microsoft] [ODBC SQL Server Driver][DBNETLIB]SSL Security error (18) (SQLDriverConnect); [08001] [Microsoft] [ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (SECDoClientHandshake()). (772)’)
As per the organization standard, TLS 1.0 is disabled on the windows server where the SQL Server is installed in the network. Since I am accessing the database via python script, we cannot temporarily enable TLS 1.0. I am looking for a direction. Any help is greatly appreciated!!
Gord Thompson pointed Guna in the right direction in the comments:
Can you try using ODBC Driver 17 for SQL Server and see if that works for you?
– Gord Thompson
Guna said that this worked:
I was facing different set of errors. While adding the port number in addition to the server name, the problem got resolved. The ODBC Driver name also needs to be updated. conn=pyodbc.connect(‘Driver={ODBC Driver 17 for SQL Server};’ ‘Server=DB_Instance,port;’ ‘Database=DB_Name;’ ‘UID=user_name;’ ‘PWD=password;’ ‘Trusted_Connection=no;’);
– Guna
Posting this as a community Wiki just so that any searchers can see quickly that it was answered.
PROBLEM: –
When trying to perform password change for MSSQL server, you get the following error message:-SSL Security error
SOLUTION: –
It’s likely an issue with the version of the SQL Native Client driver being used to establish the connection.
-
Please Download & install "ODBC Driver 13 for SQL Server" on the CPM servers.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=50420
Download 32 bit driver : x86msodbcsql.msi -
Install as usual
-
Edit MSSQL Platforms to change the connection command from
Driver={SQL Server};Server=%ADDRESS%;Database=%DATABASE%;Uid=%USER%;Pwd=%LOGONPASSWORD%;
to
Driver={ODBC Driver 13 for SQL Server};Server=%ADDRESS%;Database=%DATABASE%;Uid=%USER%;Pwd=%LOGONPASSWORD%; -
Restart the CPM service to pick up the platform changes & retest