PHP connects to MS SQL with SSL

What I want to achieve is very simple. I want to connect to an external MS SQL database from a PHP script through a secure connection. However, this turned out to be problematic, and, from three hours before the start of the research, I am at a loss.

The platform for the client is Ubuntu, which means that I cannot use SQLSRV. A secure connection has been tested with different clients and it works great. I am currently using PDO and DBlib to connect to a database, which also works great.

I could not find a way to force the connection. I tried several other drivers, but to no avail.

What are my options?

Edit: The following FreeTDS logs left me ...

config.c:543: Got a match. config.c:565: host = 'XXXXXXXXXX' config.c:595: Found host entry XXXXXXXXXX. config.c:599: IP addr is XXXXXXXXXX. config.c:565: port = '1433' config.c:565: encryption = 'require' config.c:565: check certificate hostname = 'no' config.c:629: UNRECOGNIZED option 'check certificate hostname' ... ignoring. config.c:565: ca file = 'XXXXXXXXXX.pem' config.c:629: UNRECOGNIZED option 'ca file' ... ignoring. 
+5
sql php ssl ubuntu
source share
2 answers

If you want to use PDO, you can configure PDO ODBC. You will need to configure the configuration files /etc/odbc.ini , /etc/odbcinst.ini and /etc/freetds/freetds.conf .

You will also need to install unixodbc and freetds: apt-get install unixodbc tdsodbc .

You can see more information here: Connect PHP to MSSQL via PDBC ODBC

EDIT: To enforce SSL in ODBC, add the Encrypt keyword and set it to true in the connection string. And configure SQL Server to use SSL: https://support.microsoft.com/en-us/kb/316898

EDIT 2: According to the OP, adding encryption=require and check certificate hostname to freetds.config according to the following specification: http://www.freetds.org/userguide/freetdsconf.htm along with the above steps will fix the problem

+3
source share

Did you mssql_connect secure connection? Take a look in php.ini and make sure the mssql.secure_connection parameter mssql.secure_connection set to

 [MSSQL] mssql.secure_connection = On 
+1
source share

All Articles