简体   繁体   English

连接到 IMAP 时 SSL 协商失败(Debian Bullseye)

[英]SSL negotiation failed when connecting to IMAP (Debian Bullseye)

All of a sudden my script can't connect to the IMAP server.突然之间,我的脚本无法连接到 IMAP 服务器。 It started failing during the night, so I guess something has been updated on the mail server?它在晚上开始失败,所以我猜邮件服务器上已经更新了一些东西?

I can connect via my email client Thunderbird though, but not via PHP IMAP我可以通过我的电子邮件客户端 Thunderbird 进行连接,但不能通过 PHP IMAP

Could not connect to {mail.xxx.com:143/imap/tls/novalidate-cert/user=catch-all@xxx.com}
TLS/SSL failure for mail.xxx.com: SSL negotiation failed

code代码

public function connect(string $folder=''){
        $this->mailbox  = '{'.$this->host.$this->flags.'/user='.$this->user.'}';
        $mailbox        = $folder ?: $this->mailbox;
        
        if($this->stream){
            if(!@imap_reopen($this->stream, $mailbox, 0, self::CONNECT_RETRIES)){
                throw new Error($this, "Could not connect to $mailbox");
            }
        }
        else{
            if(!$this->stream = @imap_open($mailbox, $this->user, $this->pass, 0, self::CONNECT_RETRIES)){
                throw new Error($this, "Could not connect to $mailbox");
            }
        }
        
        ...
        
        return $this->stream;
    }

update更新

The IMAP server has been updated to Debian Bullseye which only accepts TLS1.2 or newer IMAP 服务器已更新为仅接受 TLS1.2 或更高版本的Debian Bullseye

The PHP version currently installed on the client is PHP 8.1.4 and also running Debian Bullseye .当前安装在客户端的 PHP 版本是PHP 8.1.4并且还运行Debian Bullseye It should be compatible and up-to-date它应该是兼容的和最新的

Have found this "bug" https://bugs.php.net/bug.php?id=76928发现了这个“错误” https://bugs.php.net/bug.php?id=76928

Found a solution myself.自己找到了解决方案。 If you just change /tls to /ssl with port 993 it works如果您只是使用端口993/tls更改为/ssl它可以工作

The "bug" https://bugs.php.net/bug.php?id=76928 “错误” https://bugs.php.net/bug.php?id=76928

{mail.xxx.com:993/imap/ssl/novalidate-cert/user=catch-all@xxx.com}

The solution https://bugs.php.net/bug.php?id=78156解决方案https://bugs.php.net/bug.php?id=78156

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM