SMTP + SSL Configuration Problem [certificate verify failed]

SMTP + SSL Configuration Problem [certificate verify failed]

by Mark Horvat -
Number of replies: 1

Hello,

I am receiving the following error when configuring SMTP with TLS in our Moodle Server:

Using our exchange server as a relay.

Moodle Version: 3.5.2+ (Build: 20180927)

Using a XAMPP build.

---

2019-01-30 15:07:06 Connection: opening to XXXXXXXXXXXXX:587, timeout=300, options=array()
2019-01-30 15:07:06 Connection: opened
2019-01-30 15:07:06 SERVER -> CLIENT: 220 XXXXXXXXXXXX Microsoft ESMTP MAIL Service ready at Wed, 30 Jan 2019 16:07:06 +0100
2019-01-30 15:07:06 CLIENT -> SERVER: EHLO xxxxxxxxxxxxxxxx
2019-01-30 15:07:06 SERVER -> CLIENT: 250-XXXXXXXXX Hello [XXXXXXXXXXX]
                                     250-SIZE 52428800
                                     250-PIPELINING
                                     250-DSN
                                     250-ENHANCEDSTATUSCODES
                                     250-STARTTLS
                                     250-AUTH GSSAPI NTLM
                                     250-8BITMIME
                                     250-BINARYMIME
                                     250 CHUNKING
2019-01-30 15:07:06 CLIENT -> SERVER: STARTTLS
2019-01-30 15:07:06 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2019-01-30 15:07:06 Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
                                     error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
[C:\xampp\htdocs\moodle\lib\phpmailer\src\SMTP.php line 403]
2019-01-30 15:07:06 SMTP Error: Could not connect to SMTP host.
2019-01-30 15:07:06 CLIENT -> SERVER: QUIT
2019-01-30 15:07:06 SERVER -> CLIENT:
2019-01-30 15:07:06 SMTP ERROR: QUIT command failed:
2019-01-30 15:07:06 Connection: closed
2019-01-30 15:07:06 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

---

I've found several forum posts and articles online with the same error, but the problem is that I'm a complete PHP beginner. My question is; where can I define where the SSL cert is located? Is it in the php.ini or in the PHPMailer.php? Or should Moodle automatically read it out of the Windows Cert Store on the server?

Any assistance on the matter is very much appreciated.

Thank you in advance!


Average of ratings: -
In reply to Mark Horvat

Re: SMTP + SSL Configuration Problem [certificate verify failed]

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

PHP, specifically the OpenSSL extension, doesn't use the local certificate store on Microsoft Windows as far as I can see.

If you've got a copy of the certificate Exchange is using and it's a self-signed cert you can put that on your Moodle server and then set the openssl.cafile setting in php.ini to this location.

But from what little experience of Microsoft Exchange I have, I think it creates a certificate signed by its internal CA, i.e. it's not actually self-signed, so you may actually need to get a copy of the Exchange internal CA certificate and point openssl.cafile to that.

Average of ratings: Useful (1)