SSL connection error: SSL certificate validation failure (2026) (SQLDriverConnect) pyodbc?

Question:

I am trying to connect to Azure MySQL Database Service. I am using

pyodbc==3.0.3

python 2.7

My Connection string looks like this

connection_string = "DRIVER={MySQL};SERVER={server_name}.mysql.database.azure.com;PORT=3306;DATABASE" 
                        "={my_database_name};UID={username@server_name};PWD={password};CHARSET=UTF8;" 
                      "sslca=/home/sachin/BaltimoreCyberTrustRoot.crt.pem;sslverify=1"
cnxn = pyodbc.connect(connection_string)

But the same configuration works with mymysql.connector is working fine.

import mysql.connector

cnx = mysql.connector.connect(user="{username@servername}", password="{password}",
                              host="{server_name}.mysql.database.azure.com",
                              port=3306, database="{database_name}", ssl_ca="/home/sachin//root.crt",
                              ssl_verify_cert=True)
cnx.cursor()

I can not use mysql.connector for now. So need some suggestion if any one have faced this issue.

Asked By: Sachin Aryal

||

Answers:

I had the same problem and fixed it by setting sslverify=1 to sslverify=0.

e.g. for Azure:

;sslca={BaltimoreCyberTrustRoot.crt.pem}; sslverify=0; Option=3;'
Answered By: Thomas W
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.