Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: OpenSSL 3.5.1 forcing TLS 1.3 - need to limit to TLS 1.2 |
|
Author |
|
Mognar
Joined: 31 Jul 2025 Posts: 4
|
Posted: Thu 31 Jul '25 21:44 Post subject: OpenSSL 3.5.1 forcing TLS 1.3 - need to limit to TLS 1.2 |
|
|
Hi all,
Hoping to get some assistance with an issue we're running into. So we recently upgraded to Apache 2.4.64 which upgraded OpenSSL from 3.4 to 3.5.1
From all of our testing, it appears that openssl 3.5.1 is forcing TLS1.3 . We are sending mail to an smtp relay server which is limited to TLS1.2 and need to limit openssl to use TLS1.2 but have been unsuccessful.
I reverted the following files back to the OpenSSL 3.4 versions and when done, we're able to send mail without issue, so fairly confident 3.5.1 is the issue:
bin\abs.exe
bin\apr_crypto_openssl-1.dll
bin\libcrypto-3-x64.dll
bin\libssl-3-x64.dll
bin\openssl.exe
modules\mod_ssl.so
If we set SMTPAutoTLS to False, the mail goes through.
We've tried modifying the code, including the following and different variations of the follow:
$mail->SMTPAuth = false;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAutoTLS = true;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false,
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, // Explicitly force TLS 1.2
)
);
as well as using: $mail->SMTPSecure = 'tlsv1.2';
I've tried modifying the httpd-ssl.conf in the following ways:
1. Changed the ciphersuite directives
2. Tried multiple variations of the following within the vhost block:
SSLProtocol -all +TLSv1.2
SSLProtocol TLSv1.2
3. Tried multiple various of:
# intermediate configuration
SSLProtocol -all +TLSv1.2
SSLOpenSSLConfCmd Curves X25519:prime256v1:secp384r1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305
SSLHonorCipherOrder off
SSLSessionTickets off
SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"
Running s_client -connect relay.xxx.xxx:25 -starttls smtp shows that it negotiated using TLS1.3 and gets a write:errno=10060
Running s_client -connect relay.xxx.xxx:25 -starttls smtp -tls1_2 is successful.
I'm leaving a lot out, but hoping that provides enough info and I'll be happy to provide more if needed. It's been a long week, the pup needs a walk and I need a break from the monitors
So any and all advice would be appreciated at this point.
Thanks in advance!
Mog |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 392 Location: UK
|
Posted: Fri 01 Aug '25 20:26 Post subject: |
|
|
Testing locally, with appropriate Apache SSL configuration settings, OpenSSL 3.5.1 (with Apache 2.4.64/65) is able to connect to a web server using TLS 1.2.
Equally, you have proved you can s_client to your SMTP server with TLS 1.2, so this rather shows it's not a problem with OpenSSL 3.5.x libraries per se.
It would appear your problem lies with the PHP code handling the SMTP connection for the PHP mailer, and the likelihood that some function coded into your PHP is no longer available in the updated SSL libraries. Notably, OpenSSL 3.5 has replaced some ageing DES ciphers with AES replacements, which may be relevant to your SMTP connection.
Are you running the latest version of PHP, and if not are you able to update it? |
|
Back to top |
|
Mognar
Joined: 31 Jul 2025 Posts: 4
|
Posted: Fri 01 Aug '25 22:14 Post subject: |
|
|
Hi and thanks for the reply.
I'm the sys admin and this is for one of our supported dept's/servers. I don't handle any of the coding for the site and this is sort of new territory for me, which is why I posted.
This issue is that we need to use smtp servers which we don't manage and are limited to TLS1.2 due to them being on Win 2019. No plans in the near future to upgrade the smtp environment, so we have to be able to connect via 1.2.
PHP is at 8.3.23, so yes, we're current there.
Thanks
tangent wrote: | Testing locally, with appropriate Apache SSL configuration settings, OpenSSL 3.5.1 (with Apache 2.4.64/65) is able to connect to a web server using TLS 1.2.
Equally, you have proved you can s_client to your SMTP server with TLS 1.2, so this rather shows it's not a problem with OpenSSL 3.5.x libraries per se.
It would appear your problem lies with the PHP code handling the SMTP connection for the PHP mailer, and the likelihood that some function coded into your PHP is no longer available in the updated SSL libraries. Notably, OpenSSL 3.5 has replaced some ageing DES ciphers with AES replacements, which may be relevant to your SMTP connection.
Are you running the latest version of PHP, and if not are you able to update it? |
|
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 392 Location: UK
|
Posted: Sun 03 Aug '25 13:13 Post subject: |
|
|
I'm no PHP expert, but I don't understand how regressing the various OpenSSL DLL files in Apache affects your PHP SSL backend. I understood that PHP comes with its own OpenSSL library, namely php_openssl.dll (in the ext folder).
This is what I get with default settings on a test instance of PHP:
Code: | C:\Apache24\bin>httpd -v
Server version: Apache/2.4.65 (Win64)
Apache Lounge VS17 Server built: Jul 24 2025 14:32:29
C:\Apache24\bin>openssl -v
OpenSSL 3.5.1 1 Jul 2025 (Library: OpenSSL 3.5.1 1 Jul 2025)
C:\Apache24\bin>php -v
PHP 8.3.24 (cli) (built: Jul 29 2025 16:34:29) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.24, Copyright (c) Zend Technologies
C:\Apache24\bin>grep -i "^extension" C:\PHP-8.3\php.ini
extension_dir = "C:\PHP-8.3\ext"
extension=openssl
C:\Apache24\bin>php -i | grep -i openssl
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 3.0.15 3 Sep 2024
OpenSSL Header Version => OpenSSL 3.0.15 3 Sep 2024
Openssl default config => C:\Program Files\Common Files\SSL/openssl.cnf
openssl.cafile => no value => no value
openssl.capath => no value => no value
OpenSSL support => enabled
|
Indeed, if I try and force PHP to load the Apache supplied OpenSSL DLL, libcrypto-3-x64.dll, I get a PHP load error (due to differing linker versions), viz:
Code: | C:\Apache24\bin>grep -i "^extension" C:\PHP-8.3\php.ini
extension_dir = "C:\PHP-8.3\ext"
extension=C:\Apache24\bin\libcrypto-3-x64.dll
C:\Apache24\bin>php -i | grep -i openssl
PHP Warning: PHP Startup: Can't load module 'C:\Apache24\bin\libcrypto-3-x64.dll' as it's linked with 14.42, but the core is linked with 14.29 in Unknown on line 0
OpenSSL support => disabled (install ext/openssl)
|
So what settings do you have in your php.ini file and related PHP Mailer code, that manage to pick up Apache OpenSSL DLL files, rather than the PHP bundled defaults? Are you building Apache and PHP from source, so assuring no PHP linker issues? |
|
Back to top |
|
Mognar
Joined: 31 Jul 2025 Posts: 4
|
Posted: Mon 04 Aug '25 21:11 Post subject: |
|
|
Hi Tangent,
Thanks, I really appreciate your help.
The extension is enabled in the php.ini, so yes, you would think that it's using the php_openssl.dll. "extension=openssl"
Here's the code the developer is using:
<?php
require 'vendor/autoload.php'; // Adjust path if needed
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Enable verbose debug output
$mail = new PHPMailer(true);
$mail->SMTPSecure = 'TLSv1.2';
try {
// Server settings
$mail->SMTPDebug = 3; // Use 3 for full output
$mail->Debugoutput = 'html'; // Format debug as HTML
$mail->isSMTP();
$mail->Host = 'xxx.xxx.xxx';
//$mail->Host = 'xxx.xxx.xxx';
$mail->Port = 25; // Try 587 if 25 fails
//$mail->Port = 587; // Try 587 if 25 fails
//$mail->SMTPAuth = false;
//$mail->SMTPSecure = false;
//$mail->SMTPAutoTLS = true; // 👈 IMPORTANT: disables STARTTLS attempt
$mail->SMTPAuth = false;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAutoTLS = true;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false,
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, // Explicitly force TLS 1.2
)
);
//$mail->SMTPOptions = [
// 'ssl' => [
// 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
// 'verify_peer' => false,
// 'verify_peer_name' => false,
// 'allow_self_signed' => true
// ]
//];
//$mail->SMTPAuth = false;
//$mail->SMTPSecure = 'tlsv1.2';
//$mail->SMTPAutoTLS = true;
//
//$mail->SMTPOptions = [
// 'ssl' => [
// 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, // Force TLS 1.2
// 'verify_peer' => false,
// 'verify_peer_name' => false,
// 'allow_self_signed' => true,
// ]
//];
// Sender & recipient
$mail->setFrom('xxx@xxx.xxx', 'Email Testing Support');
$mail->addAddress('XXX@xxx'); // Replace with your real email
// Email content
$mail->isHTML(false);
$mail->Subject = 'SMTP Test from PHPMailer';
//$mail->Subject = 'PHP mail Test from PHPMailer';
$mail->Body = "This is a test message to verify SMTP connectivity with xxx.xxx.xxx";
//$mail->Body = "This is a test message to verify PHP mail function with Apache and OSSL";
$mail->send();
echo '<p>Email sent successfully.</p>';
} catch (Exception $e) {
echo '<p style="color:red;"><strong>Mailer Error:</strong> ' . $mail->ErrorInfo . '</p>';
If I didn't mention it prior, if he sets SMTPAutoTLS=False, the mail goes through without issue. |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 392 Location: UK
|
Posted: Tue 05 Aug '25 20:09 Post subject: |
|
|
These settings are helpful, and notably, your developer has tried various settings for $mail->SMTPSecure, and $mail->Port numbers, but the one port I'd have expected to see for an SMTPS connection is port 465. Port 25 is the historical non-secure mail service port (and port 587 for STARTTLS).
What I'd do is confirm your SMTP server supports TLS 1.2 on port 465, using the OpenSSL with Apache from a command line, viz:
Code: | c:\Apache24\bin\openssl s_client -host your_mail_server -port 465 -tls1_2
|
If successful, this should give you an interactive prompt with the mail relay, e.g. with my ISP mail relay:
Code: | ...
...
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES256-GCM-SHA384
Session-ID: 5EA4D33ACBC0D5495372B0A87C7CD4752DF9C3BB1C6FD63C04C08558AA173EF6
Session-ID-ctx:
Master-Key: BC701922BF08C25929E65EEF2AA218125A9BC3E85A8C559923898908E1409FEC7E5CAA7D58698CE89FE9970A50234A75
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 300 (seconds)
TLS session ticket:
0000 - 14 8c b9 6a 1e 54 fd fc-04 20 b8 50 27 74 67 7a ...j.T... .P'tgz
0010 - 52 98 5f c0 d1 34 4f 2b-44 ec b8 3a 5b 10 52 33 R._..4O+D..:[.R3
0020 - d5 13 b5 b9 73 54 a1 5a-a3 99 a5 8d 2a b2 98 82 ....sT.Z....*...
0030 - b6 56 4e 3c fc 76 87 f0-24 95 0e 0a 53 55 1f c4 .VN<.v..$...SU..
0040 - 8e 88 ba a2 50 9b 37 70-b0 a7 8c b3 50 be 1a f3 ....P.7p....P...
0050 - e4 39 ca 7a f4 aa 5a e3-cf 48 71 f8 67 2f 94 0c .9.z..Z..Hq.g/..
0060 - 77 25 9a 9b 65 e5 ca 5c-30 61 7f 5e 20 6a b1 c1 w%..e..\0a.^ j..
0070 - df 70 d7 70 88 d4 ff 82-e5 66 0d 91 fc d2 85 a2 .p.p.....f......
0080 - dc 36 3e 3f be a0 db d4-80 36 8d 04 aa 72 3c 25 .6>?.....6...r<%
0090 - 62 ed d0 a6 47 5e 9f 30-cf af 02 6e d1 06 aa 5a b...G^.0...n...Z
00a0 - 51 7c 09 97 03 89 d1 0f-c4 39 d2 bc f7 1c 86 da Q|.......9......
Start Time: 1754415888
Timeout : 7200 (sec)
Verify return code: 20 (unable to get local issuer certificate)
Extended master secret: yes
---
220 avasout-ptp-003 smtp relay.plus.net
quit
221 avasout-ptp-003 smtp closing connection
closed
|
If you try the above command against your mail relay with port 25 or port 587, I doubt it will accept the connection.
Having proved your mail relay accepts an TLSv1.2 connection, adjust your PHP Mailer port variable accordingly, e.g.
Code: | $mail->Port = 465
$mail->SMTPSecure = 'tls';
|
Hope this helps. |
|
Back to top |
|
Mognar
Joined: 31 Jul 2025 Posts: 4
|
Posted: Thu 07 Aug '25 18:56 Post subject: |
|
|
Sorry for the late reply, had an injury with the family pet I've been dealing with all week.
I checked and as expected, 465 is no longer active on the relay servers as it's no longer a supported smtp port. (Not RFC compliant) |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 392 Location: UK
|
Posted: Thu 07 Aug '25 21:31 Post subject: |
|
|
Ok, so next I'd confirm exactly what level of secure connection your mail server supports when using STARTTLS, i.e.
Code: | c:\Apache24\bin\openssl s_client -host your_mail_server -port 25 -starttls smtp
|
This opens a standard SMTP connection on port 25 and then upgrades it to a secure connection through STARTTLS. OpenSSL will, I believe, negotiate the most secure connection both ends can agree on; in my case TLS 1.2, as previously shown against my ISP mail relay. You can add -debug to see more detail during the connection process.
If the above command connects to your Win 2019 mail server with TLS 1.2, then it shows that the OpenSSL 3.5.1 libraries are capable of supporting TLS 1.2, rather than mandating TLS 1.3, in which case it rather looks like a PHP Mailer configuration issue.
You say you've tried various combinations of the PHP Mailer variables, so what happens if you regress back to the basic minimal entries (with no $mail->SMTPOptions array, etc.):
Code: | $mail->SMTPDebug = 3; // Use 3 for full output
$mail->Debugoutput = 'html'; // Format debug as HTML
$mail->isSMTP();
$mail->Host = 'xxx.xxx.xxx';
$mail->Port = 25;
$mail->SMTPSecure = 'tls';
|
Presume the SMTPDebug is producing some useful output that gives a clue over the connection setup process? Also assume your PHP Mailer is up to date (latest release is 6.10.0)?
Beyond this, I don't think there's anything more I can suggest, apart from wishing you good luck homing in on the problem component! |
|
Back to top |
|
|
|
|
|
|