簡體   English   中英

SSL3_GET_SERVER_CERTIFICATE證書在Windows 10 Pro with IIS上驗證失敗

[英]SSL3_GET_SERVER_CERTIFICATE certificate verify failed on Windows 10 Pro with IIS

嘗試在Windows 10上通過IIS托管的PHP通過PHPMailer通過smtp.google.com發送電子郵件時,出現以下錯誤消息:

Connection failed. 
Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. 
OpenSSL Error messages
error:14090086
SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

我確定該錯誤的關鍵部分是證書驗證失敗 我正在運行OpenSSL,它已啟用並鏈接到我的php。 這是我的本地PHP實例輸出的一些信息:

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.1p 9 Jul 2015
OpenSSL Header Version => OpenSSL 1.0.1p 9 Jul 2015

Directive => Local Value => Master Value
openssl.cafile => no value => no value
openssl.capath => no value => no value

這是我的PHP代碼:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';

$mail = new PHPMailer;
$mail->isSMTP(); 
$mail->SMTPDebug = 2; // 0 = off (for production use) - 1 = client messages - 2 = client and server messages
$mail->Host = "smtp.gmail.com"; // use $mail->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6
$mail->Port = 587; // TLS only
$mail->SMTPSecure = 'tls'; // ssl is depracated
$mail->SMTPAuth = true;
$mail->Username = $smtpUsername;
$mail->Password = $smtpPassword;
$mail->setFrom($emailFrom, $emailFromName);
$mail->addAddress($emailTo, $emailToName);
$mail->Subject = 'PHPMailer GMail SMTP test';
$mail->msgHTML("test body"); //$mail->msgHTML(file_get_contents('contents.html'), __DIR__); //Read an HTML message body from an external file, convert referenced images to embedded,
$mail->AltBody = 'HTML messaging not supported';
// $mail->addAttachment('images/phpmailer_mini.png'); //Attach an image file

if(!$mail->send()){
    echo "Mailer Error: " . $mail->ErrorInfo;
}else{
    echo "Message sent!";
}

我對OpenSSL和證書問題不甚了解。 我試圖理解《 PHPMailer故障排除指南》中的“ 更新CA證書”部分,但我感到迷茫和困惑。 有人可以給我提供一些步驟,以便我可以在本地Windows 10計算機上執行並修復證書問題嗎?

要解釋該指南,請從curl下載CA軟件包並將其存儲在文件系統中的某個位置。 采取將其保存到的路徑,並在php.ini文件中添加一行,內容為:

openssl.cafile = $path

$ path是將CA證書保存到的位置。 然后重新啟動您的Web服務器以獲取ini更改。

如果可行,您應該在phpinfo()的輸出中看到該設置,並且還應該向PHP提供在PHPMailer使用證書時驗證證書所需的內容。 請注意,如果服務器出示的證書真正無效或已過期,這將無濟於事,但是鑒於這是眾所周知的問題和解決方案,我希望它能夠正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM