Debian 10 – msphpsql – php 7.3 to MS SQL Error 0x2746

Installed the PHP driver for MS SQL on a vanilla Debian 10 VM, using:

# Escalate
sudo su


apt-get install curl apt-transport-https
wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update
apt-get install -y php7.3 php7.3-dev php7.3-xml php7.3-intl
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
pecl install sqlsrv
pecl install pdo_sqlsrv
printf "; priority=20\\n" > /etc/php/7.3/mods-available/sqlsrv.ini
printf "; priority=30\\n" > /etc/php/7.3/mods-available/pdo_sqlsrv.ini
phpenmod -v 7.3 sqlsrv pdo_sqlsrv


curl | apt-key add -
curl > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

As per the docs. Then connecting gives this error in PHP:

Failed to connect to database: [0] SQLSTATE: 08001 code: 10054 message: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746[1] SQLSTATE: 08001 code: 10054 message: [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection

And this on the server (SQL Server 2012):

A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 1205.

Lots of chat about this on the forums ( ) but this comment by miktea is the key:

Modify /etc/ssl/openssl.cnf config file:

CipherString = DEFAULT@SECLEVEL=2 


About: Rob