Skip to main content

pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]


Recently, I faced this error in our Docker-Container environment. All the necessary packages were already installed but still, I was facing this clueless error. I search a bit and after an hour and so I found the exact reason and solution for this error.

To know more about this error in detail. Please follow this Github thread.

https://github.com/mkleehammer/pyodbc/issues/610

https://github.com/mkleehammer/pyodbc/issues/610#issuecomment-587523802


Solution: It's because the server's certificate has too weak a key.

In case you are using Linux env directly/not the Docker one. Just edited /etc/ssl/openssl.cnf and change these 2 lines.

MinProtocol = TLSv1.0
CipherString = DEFAULT@SECLEVEL=1

In case you are also using a container, please add these three lines to your Docker file.

RUN chmod +rwx /etc/ssl/openssl.cnf
RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/SECLEVEL=2/SECLEVEL=1/g' /etc/ssl/openssl.cnf

Thanks!! Enjoy Programming!


Reference Links:

https://github.com/mkleehammer/pyodbc/issues/610





Comments

  1. I appreciate you taking the time and effort to share your knowledge. This material proved to be really efficient and beneficial to me. Thank you very much for providing this information. Continue to write your blog.

    Data Engineering Services 

    Data Analytics Solutions

    Artificial Intelligence Solutions

    Data Modernization Services

    ReplyDelete

Post a Comment

Thanks for your valuable comments.