SSL Connection Error with ODBC Driver 18 on ARM Linux

I’m having trouble connecting to a SQL Server database from my ARM-based Linux machine using Python. The database is running on a Windows Server and I keep getting SSL errors.

Here’s my connection setup:

import urllib
from sqlalchemy import create_engine
import os
from dotenv import load_dotenv
from sqlalchemy.orm import sessionmaker

load_dotenv()

class DatabaseManager:
    host = str(os.getenv('DATABASE_HOST')) + "," + str(os.getenv('DATABASE_PORT'))
    db_name = os.getenv('DATABASE_NAME')
    user = os.getenv('DATABASE_USER')
    pwd = os.getenv('DATABASE_PASSWORD')
    connection_string = ('DRIVER={ODBC Driver 18 For SQL Server};SERVER=' + host + ';DATABASE=' + str(db_name) +
                        ';UID=' + user + ';PWD=' + pwd + ";Encrypt=no;TrustServerCertificate=yes")
    db_engine = create_engine("mssql+pyodbc:///?odbc_connect=%s" % connection_string, pool_size=10, max_overflow=20)
    
    def get_session(self):
        Session = sessionmaker(bind=self.db_engine)
        session = Session()
        return session

The error I’m getting is:

sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) (‘08001’, ‘[08001] [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:0A000102:SSL routines::unsupported protocol] (-1) (SQLDriverConnect)’)

I tried using ODBC Driver 17 but it doesn’t work on ARM Linux. The SQL Server version is Microsoft SQL Server 2012. Any ideas how to fix this SSL issue?

I encountered similar SSL issues when transitioning from x86 to ARM Linux due to OpenSSL 3.x enforcing stricter protocols. A practical solution is to modify your OpenSSL configuration file—usually located at /etc/ssl/openssl.cnf—by adding a legacy provider section. Alternatively, you can set the OPENSSL_CONF environment variable to use a custom configuration that permits legacy algorithms. While compiling an older version of OpenSSL specifically for database connections is an option, it can be complex to maintain.

what service packs are u running on sql server 2012? older versions get weird with newer odbc drivers and ssl requirements. try adding specific ssl cipher settings to your connection string. also, test the connection with sqlcmd first - does that work?

this looks like a tls version mismatch. sql server 2012 doesn’t play nice with tls 1.2+. try adding minprotocolversion=tlsv1.0 or maxprotocolversion=tlsv1.1 to your connection string. also check if your arm system’s openssl version is too new for that old sql server.