I am creating a connection php file between SQL Server and PHP 8.1.
My code is the following:
<?php
$serverName = "Server\MSSQLSERVER, 1433";
$connectionInfo = array("Database"=>"Name",
"UID"=>"User",
"PWD"=>"Password";
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
//echo "Conexión establecida.<br />";
}else{
echo "Conexión no se pudo establecer.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
But, I'm getting this error:
SQL Error: Error information: SQLSTATE: 08001 Code: -1 Message:
[Microsoft][ODBC Driver 18 for SQL Server]SSL Provider:
[error:0A000102:SSL routines::unsupported protocol][error:0A0000C7:SSL
routines::peer did not return a certificate] SQLSTATE: 08001 Code: -1
Message: [Microsoft][ODBC Driver 18 for SQL Server]Client unable to
establish connection
What could be the solution?
My Answer:
It looks like the issue might be related to SSL/TLS settings in your SQL Server configuration. Here are a few things you can try to resolve this issue:
1. Check the SQL Server Configuration Manager: Make sure that the SQL Server is configured to allow SSL connections. You may need to enable SSL encryption in the SQL Server Configuration Manager.
2. Check the SQL Server Network Configuration: Make sure that the SQL Server is configured to allow remote connections. You may need to enable TCP/IP protocol and specify the port number (1433) in the SQL Server Network Configuration.
3. Check the PHP ODBC Driver: Make sure that the PHP ODBC driver is properly installed and configured. You may need to update the ODBC driver to a version that supports SSL/TLS connections.
4. Check the PHP SQLSRV Driver: Make sure that the PHP SQLSRV driver is properly installed and configured. You may need to update the SQLSRV driver to a version that supports SSL/TLS connections.
5. Check the SQL Server Certificate: Make sure that the SQL Server has a valid SSL certificate installed. You may need to configure the SQL Server to use a trusted SSL certificate.
If none of these solutions work, you may need to consult with your network administrator or IT department to troubleshoot the SSL/TLS connection issue further.
Rate this post
4 of 5 based on 7558 votesComments