我最近从IIS Express切换到Windows Server上的IIS。在进行迁移时,我遇到了识别PHP的问题,我安装了ODBC,等等。然而,我得到了以下错误,即使我已经有一个SSL证书。
Array
(
[0] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => -2146893019
[code] => -2146893019
[2] => [Microsoft][ODBC Driver 18 for SQL Server]SSL
Provider: The certificate chain was issued by an authority that is not
trusted.
[message] => [Microsoft][ODBC Driver 18 for SQL Server]SSL
Provider: The certificate chain was issued by an authority that is not
trusted.
)
[1] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => -2146893019
[code] => -2146893019
[2] => [Microsoft][ODBC Driver 18 for SQL Server]Client
unable to establish connection
[message] => [Microsoft][ODBC Driver 18 for SQL
Server]Client unable to establish connection
)
)
我想相信问题出在连接的设置上。数据库版本为Microsoft SQL Server 2019。
<?php
$serverName = "//serverNameinstanceName";
$connectionInfo = array( "Database"=>"Database", "UID"=>"UID","PWD"=>"PWD");
$connection = sqlsrv_connect( $serverName, $connectionInfo);
if( !$connection ) {
die(print_r( sqlsrv_errors(), true));
}
?>
为连接信息添加参数
Encrypt=true;TrustServerCertificate=true;
有人建议TrustServerCertificate=Yes;这不会工作,也不会给出错误