[Microsoft][ODBC Driver 18 for SQL Server]SSL 提供程序:证书链由不受信任的机构颁发

问题描述 投票:0回答:1

我收到错误

[Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted.
具有最新版本的学说。

数据库连接代码

$Params = [
    'dbname' => 'XXX',
    'user' => 'XXX',
    'password' => 'XXX',
    'host' => 'XXXX',
    'driver' => 'sqlsrv',
    'Encrypt' => 0,
    'TrustServerCertificate' => 1,
];
$conn = DriverManager::getConnection($Params);

查询

$queryBuilder = $conn->createQueryBuilder();
$queryBuilder
    ->select('*')
    ->from('Job, JobDetail, JobStateChronic')
    ->where('Job.JobDetailID = JobDetail.JobDetailID AND Job.JobDetailID = JobStateChronic.JobDetailID')
    ->andWhere('YEAR(Job.StartDate) = ? AND MONTH(Job.StartDate) = ? AND DAY(Job.StartDate) = ?')
    ->setParameter(0, '2023')
    ->setParameter(1, '04')
    ->setParameter(3, '24')

;
$stm = $queryBuilder->executeQuery();
$data = $stm->fetchAllAssociative();

echo "<pre>";
print_r($data);
echo "</pre>";

我使用 Wampserver 3.3.1 作为我的网络服务器。 在我将 php 版本从 8.2.0 更新到 8.2.9 之前,它工作正常

这是完整的错误

[05.08.2023 - 12:10:49] [ERROR] [Uncaught Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred in the driver: SQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted.  SQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722" at C:\wamp64\www\taxihof-manager\vendor\doctrine\dbal\src\Driver\API\SQLSrv\ExceptionConverter.php line 67] {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: -2146893019): An exception occurred in the driver: SQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted.\r\n\nSQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722 at C:\\wamp64\\www\\taxihof-manager\\vendor\\doctrine\\dbal\\src\\Driver\\API\\SQLSrv\\ExceptionConverter.php:67)\n[previous exception] [object] (Doctrine\\DBAL\\Driver\\SQLSrv\\Exception\\Error(code: -2146893019): SQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted.\r\n\nSQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722 at C:\\wamp64\\www\\taxihof-manager\\vendor\\doctrine\\dbal\\src\\Driver\\SQLSrv\\Exception\\Error.php:42)"} []

我尝试将

TrustServerCertificate
Encrypt
一起使用,之前效果很好。

php sql-server doctrine sqlsrv
1个回答
0
投票

我发现问题了。我的 SQL Server 使用的是 V17,并且我在 PC 上安装了 ODBC 驱动程序 18。在我的电脑上安装 ODBC 驱动程序 17 后它就可以工作了。

© www.soinside.com 2019 - 2024. All rights reserved.