久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

12下一頁
返回列表 發帖
查看: 5155|回復: 14

[已解決] 還是 discuz 3.4 郵件設置問題

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
#
發表于 2022-8-9 07:09:59 | 只看樓主 |只看大圖 |正序瀏覽 |閱讀模式
1、如圖所示,同樣的php.ini配置,在 php 7.4 下 25 端口可以正常收發郵件, 465 端口就不行(日志錯誤是 CONNECT - Unable to connect to the SMTP server),而用 php 5.5, 25 和 465 端口都可以正常收發郵件。

2、網上的文章


希望高手能排查
1 貢獻

最佳答案

新環境c7、php7.4、openssl1.1.1g,再discuz里發送郵件總是報ssl連接不上
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
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
15#
 樓主| 發表于 2022-8-12 06:04:35 | 只看Ta
專家 發表于 2022-8-12 01:40
不能這么說,畢竟證書校驗也是ssl安全性的一環,而且是php單方面默認啟用的,這不能怪Discuz。 ...

是的,更新的時候建議能升級下
回復

使用道具 舉報

12

主題

1655

回帖

2814

積分

Giter

貢獻
151 點
金幣
362 個
14#
發表于 2022-8-12 01:40:17 | 只看Ta
zhansh 發表于 2022-8-10 22:38
以上是網上查到的資料,discuz 連接 SSL 確實是存在問題的

不能這么說,畢竟證書校驗也是ssl安全性的一環,而且是php單方面默認啟用的,這不能怪Discuz。
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
13#
 樓主| 發表于 2022-8-11 21:02:35 | 只看Ta

我湊活著解決了,可以用。
回復

使用道具 舉報

5

主題

130

回帖

158

積分

應用開發者

貢獻
0 點
金幣
14 個
QQ
12#
發表于 2022-8-11 13:01:13 | 只看Ta
我也想知道
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
11#
 樓主| 發表于 2022-8-10 22:38:48 | 只看Ta
以上是網上查到的資料,discuz 連接 SSL 確實是存在問題的
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
10#
 樓主| 發表于 2022-8-10 22:38:18 | 只看Ta
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.
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
9#
 樓主| 發表于 2022-8-10 22:32:58 | 只看Ta
新環境c7、php7.4、openssl1.1.1g,再discuz里發送郵件總是報ssl連接不上
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
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
8#
 樓主| 發表于 2022-8-10 20:52:55 | 只看Ta
crx349 發表于 2022-8-10 16:21
沒配置 證書你截圖上的ssl怎么來的?

你這一說,我發現 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=
回復

使用道具 舉報

37

主題

164

回帖

316

積分

爐火純青

貢獻
0 點
金幣
97 個
7#
 樓主| 發表于 2022-8-10 20:39:50 | 只看Ta
不需要證書,跑偏了,我在 php 5.5 郵件系統是正常使用的,php 7.4 不行
回復

使用道具 舉報

19

主題

2196

回帖

3311

積分

應用開發者

貢獻
74 點
金幣
629 個
QQ
6#
發表于 2022-8-10 16:21:05 | 只看Ta

沒配置 證書你截圖上的ssl怎么來的?
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

  • 關注公眾號
  • 有償服務微信
  • 有償服務QQ

手機版|小黑屋|Discuz! 官方交流社區 ( 皖ICP備16010102號 |皖公網安備34010302002376號 )|網站地圖|star

GMT+8, 2025-9-20 08:50 , Processed in 0.091438 second(s), 36 queries .

Powered by Discuz! W1.0 Licensed

Copyright © 2001-2025 Discuz! Team.

關燈 在本版發帖
有償服務QQ
有償服務微信
返回頂部
快速回復 返回頂部 返回列表