[sqlalchemy][mssql][tls1.2] How To Enforce Tls 1.2 For Sqlalchemy Connecting To Ms Sql Server Using Pyodbc From Windows?
Recent hardening standards have made us disable TLS 1.0 and 1.1. Registry Settings for TLS 1.0 and 1.1: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANN
Solution 1:
Further investigation showed an issue with the ODBC driver.
The app was on Windows Server 2012 with ODBC version:
SQL Server Native Client 11.0
Version:
2011.110.3000.00
Date: 10/20/2012
Updating the driver to ODBC Driver 17 for SQL Server
with new connection string worked:
from sqlalchemy import create_engine
db = create_engine(
"mssql+pyodbc://__OUR_SERVER_NAME__/__OUR_DATABSE_NAME__?driver=ODBC+Driver+17+for+SQL+Server&Trusted_Connection=yes&Encrypt=yes&TrustServerCertificate=Yes&ssl=True",
connect_args={
# 'sslmode': 'require', # did not work# 'tls-version': 'tls1.2', # did not work# 'ssl': True, # did not work
},
echo=True,
)
Post a Comment for "[sqlalchemy][mssql][tls1.2] How To Enforce Tls 1.2 For Sqlalchemy Connecting To Ms Sql Server Using Pyodbc From Windows?"