I do have a docker container for a proxy (nginx), user interface and API (.NET 6). The API is giving me an error of A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption( ssl /tls) handshake failed).
Deployment Environment: CentOS 7
SQL Server Version: Microsoft SQL 2016 SP2
Connection String: Data Source=${DB_HOST};Initial Catalog=${DB_NAME};Persist Security Info=True;User ID=${DB_USERNAME};Password=${DB_PASSWORD};MultipleActiveResultSets=True
Solutions I'd tried:
TrustServerCertificate=True or Encrypt=False in the connection string.RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnfNothing worked from all of this solutions. Badly needed help!
I just solved my concern by combining the following.
Microsoft.Data.SqlClient instead of Systems.Data.SqlClient.RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf
TrustServerCertificate=True to connection string of the database.This lowers the TLS version of docker image or container to TLSv1. However, this is not the best solution. It would be better to upgrade the SQL server to allow the connection to accept TLSv1.2. Which in my case is not applicable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With