Skip to content

Commit cb4d5c2

Browse files
committed
Set default crypto method - Fix #31105
1 parent 2071973 commit cb4d5c2

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

Smtp/Stream/SocketStream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public function initialize(): void
140140
if ($this->streamContextOptions) {
141141
$options = array_merge($options, $this->streamContextOptions);
142142
}
143+
if ($this->isTLS()) {
144+
$options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
145+
}
143146
$streamContext = stream_context_create($options);
144147
$this->stream = @stream_socket_client($this->url, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $streamContext);
145148
if (false === $this->stream) {

SocketStream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public function initialize(): void
140140
if ($this->streamContextOptions) {
141141
$options = array_merge($options, $this->streamContextOptions);
142142
}
143+
if ($this->isTLS()) {
144+
$options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
145+
}
143146
$streamContext = stream_context_create($options);
144147
$this->stream = @stream_socket_client($this->url, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $streamContext);
145148
if (false === $this->stream) {

Stream/SocketStream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public function initialize(): void
140140
if ($this->streamContextOptions) {
141141
$options = array_merge($options, $this->streamContextOptions);
142142
}
143+
if ($this->isTLS()) {
144+
$options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
145+
}
143146
$streamContext = stream_context_create($options);
144147
$this->stream = @stream_socket_client($this->url, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $streamContext);
145148
if (false === $this->stream) {

Transport/Smtp/Stream/SocketStream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public function initialize(): void
140140
if ($this->streamContextOptions) {
141141
$options = array_merge($options, $this->streamContextOptions);
142142
}
143+
if ($this->isTLS()) {
144+
$options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
145+
}
143146
$streamContext = stream_context_create($options);
144147
$this->stream = @stream_socket_client($this->url, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $streamContext);
145148
if (false === $this->stream) {

0 commit comments

Comments
 (0)