1、如圖所示,同樣的php.ini配置,在 php 7.4 下 25 端口可以正常收發郵件, 465 端口就不行(日志錯誤是 CONNECT - Unable to connect to the SMTP server),而用 php 5.5, 25 和 465 端口都可以正常收發郵件。 ... 查看全文
zhansh 發表于 2022-8-10 22:38 不能這么說,畢竟證書校驗也是ssl安全性的一環,而且是php單方面默認啟用的,這不能怪Discuz。 |
我也想知道 |
以上是網上查到的資料,discuz 連接 SSL 確實是存在問題的 |
PHP 5.6.x中OpenSSL的變化 ? 使用SSL/TLS時,流包裝現在默認情況下會驗證對等證書和主機名 ? 默認情況下,所有加密的客戶端流現在都啟用對等驗證。默認情況下,這將使用OpenSSL的默認CA包來驗證對等證書。在大多數情況下,與具有有效SSL證書的服務器通信不需要進行任何更改,因為發行商通常將OpenSSL配置為使用已知良好的CA包。 通過設置openssl.cafile或openssl.capath配置設置,可以在全局基礎上覆蓋默認CA包,或者通過使用cafile或者capath上下文選項。 雖然通常不建議這樣做,但是可以通過設置verify_peer上下文選項到false,并通過設置verify_peer_name上下文選項到false. |
![]() Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /www/a.php on line 5 Warning: fsockopen(): Failed to enable crypto in /www/a.php on line 5 Warning: fsockopen(): unable to connect to ssl://smtp.exmail.qq.com:465 (Unknown error) in /www/a.php on line 5 以上是測試結果 找了google和度娘都沒有解決,說什么證書問題 最后看到個修改方法的,臨時用一下 修改 source/function/function_core.php 注釋原來的函數,新增以下方法 function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) { $fp = ''; if(function_exists('stream_socket_client')) { $contextOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false ) ); $context = stream_context_create($contextOptions); $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout,STREAM_CLIENT_CONNECT, $context); } return $fp; } 測試后可以正常放郵件,就是以后dz升級要注意下這塊或者重新編譯系統環境。 原文提示 一個php系統很早的了,后來把環境升級換成https與php5.6以后發現通信api不工作,通過排查發現是fsockopen函數的問題: 報錯:Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate 解決方法法改造一下fsockopen方法: //不驗證證書 $contextOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false ) ); //如果有簽名的證書 /* $contextOptions = array( 'ssl' => array( 'verify_peer' => true, 'cafile' => '/path/to/cacert.pem', //'CN_match' => 'xcwmoon.net', // 匹配域名 'ciphers' => 'HIGH:!SSLv2:!SSLv3', 'disable_compression' => true, ) ); */ $context = stream_context_create($contextOptions); $fp = stream_socket_client("ssl://{$host}:{$port}", $errno, $errstr, $timeout, STREAM_CLIENT_CO |
crx349 發表于 2022-8-10 16:21 你這一說,我發現 5.5 之后版本的php.ini都多了下面一節,之前版本是沒有的 [openssl] ; The location of a Certificate Authority (CA) file on the local filesystem ; to use when verifying the identity of SSL/TLS peers. Most users should ; not specify a value for this directive as PHP will attempt to use the ; OS-managed cert stores in its absence. If specified, this value may still ; be overridden on a per-stream basis via the "cafile" SSL stream context ; option. ;openssl.cafile= ; If openssl.cafile is not specified or if the CA file is not found, the ; directory pointed to by openssl.capath is searched for a suitable ; certificate. This value must be a correctly hashed certificate directory. ; Most users should not specify a value for this directive as PHP will ; attempt to use the OS-managed cert stores in its absence. If specified, ; this value may still be overridden on a per-stream basis via the "capath" ; SSL stream context option. ;openssl.capath= |
不需要證書,跑偏了,我在 php 5.5 郵件系統是正常使用的,php 7.4 不行 |
手機版|小黑屋|Discuz! 官方交流社區
( 皖ICP備16010102號 |皖公網安備34010302002376號 )|網站地圖|
GMT+8, 2025-9-19 01:56 , Processed in 0.130783 second(s), 35 queries .
Powered by Discuz! W1.0 Licensed
Copyright © 2001-2025 Discuz! Team.