[英]PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1
[英]Warning: stream_socket_enable_crypto(): SSL operation failed with code 1
我有CSCart的問題,它無法通過谷歌帳戶發送郵件。 要檢查服務器配置或CSCart腳本中是否存在問題,我安裝了干凈的PHPMailer庫並嘗試使用示例腳本發送測試消息。 結果是一樣的:
Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in [script path]/class.smtp.php on line 338
來自控制台的OpenSSL連接運行良好。
FreeBSD 10.0,Apache24,php5.6。
我在谷歌找不到任何信息,現在我甚至不知道在哪個配置文件中搜索問題根目錄。
這是由於PHP 5.6中新的默認驗證策略。 它沒有在php.ini中設置; 它是一個為fopen包裝器或流上下文提供的選項。 看看這里的選項,尤其是verify_peer
。 PHPMailer允許您在smtpConnect()
方法中設置這些參數,但是沒有選項將選項傳遞給smtpSend()
方法,因此您需要將PHPMailer子類化以實現它。
您可能會發現替代方案更簡單 - 不要嘗試使用自簽名或無法驗證的證書 。
有很多配置會導致出現此錯誤,但更常見的是您的系統配置未正確設置。 要正確執行,請按照下列步驟操作:
檢查您是否有OPENSSL的cacert.pem文件。 如果不這樣做,請根據您的php版本從cacert.pem下載正確的版本,並將您的php.ini文件配置為“2”
如果您有此文件,則必須在php.ini文件中查找並查看是否已在其中設置。 為此:查找行:
openssl.cafile ="example address..\\cacert.pem"
如果您找到具有特定地址的行,請查找該地址中的cacert.pem文件(如果找到),而不是使用cacert.pem文件完成。 否則,您應該使用正確的地址。
在laRAVEL 5.4錯誤
C:\\ XAMPP \\ htdocs中\\ itis_db \\供應商\\ swiftmailer \\ swiftmailer \\ LIB \\類\\雨燕\\傳輸\\ StreamBuffer.php
並在StreamBuffer.php
找到此函數
private function _establishSocketConnection()
並將此兩行粘貼到此函數內
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
並重新加載您的瀏覽器並嘗試再次運行您的項目。 對我來說,我穿上這樣:
private function _establishSocketConnection()
{
$host = $this->_params['host'];
if (!empty($this->_params['protocol'])) {
$host = $this->_params['protocol'].'://'.$host;
}
$timeout = 15;
if (!empty($this->_params['timeout'])) {
$timeout = $this->_params['timeout'];
}
$options = array();
if (!empty($this->_params['sourceIp'])) {
$options['socket']['bindto'] = $this->_params['sourceIp'].':0';
}
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host '.$this->_params['host'].
' ['.$errstr.' #'.$errno.']'
);
}
if (!empty($this->_params['blocking'])) {
stream_set_blocking($this->_stream, 1);
} else {
stream_set_blocking($this->_stream, 0);
}
stream_set_timeout($this->_stream, $timeout);
$this->_in = &$this->_stream;
$this->_out = &$this->_stream;
}
希望你能解決這個問題.....
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.