awesomemotive / WP-Mail-SMTP

The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 3 million sites.
https://wordpress.org/plugins/wp-mail-smtp/
GNU General Public License v3.0
55 stars 34 forks source link

doesn't work with SSL certificates that utilise SANs #124

Open doubledrat opened 1 year ago

doubledrat commented 1 year ago

Expected Behavior

should work with certificates that contain SANs

Current Behavior

I’m getting the following error

“SMTP Error: Could not connect to SMTP host. Connection failed. stream_socket_enable_crypto(): Peer certificate CN=int-srv-g6-1.xxx.xxx' did not match expected CN=smtp.xxx.xxx’ SMTP server error: QUIT command failed”

the certificate in question DOES have smtp.xxx.xxx as a SAN subject alternate name. int-srv-g6-1 is the SPN subject principle name.

It seems your plugin is only checking the SPN and not the available SANs

Possible Solution

check SPN and SANs for a match to the host name

Steps to Reproduce

use a certificate where the host name is a SAN

capuderg commented 1 year ago

Hi @doubledrat,

thank you for opening this issue.

Our plugin does not perform any special SSL checks. We are using WordPress's default PHPMailer class settings. It looks like for SAN support you would have to modify our MailCatcherV6 class and overwrite the $SMTPOptions public attribute with these values:

public $SMTPOptions = [
  'ssl' => [
    'verify_peer' => true,
    'peer_name' => 'smtp.xxx.xxx',
    'verify_peer_name' => true
  ]
];

Here is a bit more info about this issue in PHPMailer repository: https://github.com/PHPMailer/PHPMailer/issues/1113

Please give this a try and let us know if this resolved the issue for you.