8000 bug #37961 [Mailer] Fixed 'verify_peer' option in mailer DSN being ig… · symfony/symfony@0d99044 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d99044

Browse files
committed
bug #37961 [Mailer] Fixed 'verify_peer' option in mailer DSN being ignored (SnakePin)
This PR was squashed before being merged into the 5.1 branch. Discussion ---------- [Mailer] Fixed 'verify_peer' option in mailer DSN being ignored | Q | A | ------------- | --- | Branch? | 5.1 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | N/A <!-- required for new features --> The mailer DSN option 'verify_peer' was being ignored because `$dsn->getOption('verify_peer', true)` was returning a string and thus NOT operator on it was always resulting in false. I propose changing the line where it is used with a `filter_var` call with the `FILTER_VALIDATE_BOOLEAN` as the filter parameter to overcome this issue. Commits ------- 1c789e8 [Mailer] Fixed 'verify_peer' option in mailer DSN being ignored
2 parents 76dc182 + 1c789e8 commit 0d99044

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,22 @@ public function createProvider(): iterable
8181
new Dsn('smtps', 'example.com', '', '', 465, ['verify_peer' => false]),
8282
$transport,
8383
];
84+
85+
yield [
86+
new Dsn('smtps', 'example.com', '', '', 465, ['verify_peer' => 'false']),
87+
$transport,
88+
];
89+< 8000 div class="diff-text-inner">
90+
yield [
91+
Dsn::fromString('smtps://:@example.com?verify_peer=0'),
92+
$transport,
93+
];
94+
95+
$transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger);
96+
97+
yield [
98+
Dsn::fromString('smtps://:@example.com?verify_peer='),
99+
$transport,
100+
];
84101
}
85102
}

src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function create(Dsn $dsn): TransportInterface
2929

3030
$transport = new EsmtpTransport($host, $port, $tls, $this->dispatcher, $this->logger);
3131

32-
if (!$dsn->getOption('verify_peer', true)) {
32+
if ('' !== $dsn->getOption('verify_peer') && !filter_var($dsn->getOption('verify_peer', true), FILTER_VALIDATE_BOOLEAN)) {
3333
/** @var SocketStream $stream */
3434
$stream = $transport->getStream();
3535
$streamOptions = $stream->getStreamOptions();

0 commit comments

Comments
 (0)
0