-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
#41935 smtp: allow self-signed certificates on localhost #46957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -280,8 +280,9 @@ protected function getInstance(): MailerInterface { | |||||||||||||||||||||||||||||||||||||||||
| protected function getSmtpInstance(): EsmtpTransport { | ||||||||||||||||||||||||||||||||||||||||||
| // either null or true - if nothing is passed, let the symfony mailer figure out the configuration by itself | ||||||||||||||||||||||||||||||||||||||||||
| $mailSmtpsecure = ($this->config->getSystemValue('mail_smtpsecure', null) === 'ssl') ? true : null; | ||||||||||||||||||||||||||||||||||||||||||
| $mailSmtphost = $this->config->getSystemValueString('mail_smtphost', '127.0.0.1'); | ||||||||||||||||||||||||||||||||||||||||||
| $transport = new EsmtpTransport( | ||||||||||||||||||||||||||||||||||||||||||
| $this->config->getSystemValueString('mail_smtphost', '127.0.0.1'), | ||||||||||||||||||||||||||||||||||||||||||
| $mailSmtphost, | ||||||||||||||||||||||||||||||||||||||||||
| $this->config->getSystemValueInt('mail_smtpport', 25), | ||||||||||||||||||||||||||||||||||||||||||
| $mailSmtpsecure, | ||||||||||||||||||||||||||||||||||||||||||
| null, | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -304,6 +305,17 @@ protected function getSmtpInstance(): EsmtpTransport { | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| $currentStreamingOptions = array_merge_recursive($currentStreamingOptions, $streamingOptions); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** @psalm-suppress InternalMethod */ | ||||||||||||||||||||||||||||||||||||||||||
| $stream->setStreamOptions($currentStreamingOptions); | ||||||||||||||||||||||||||||||||||||||||||
| } else if ($mailSmtphost === 'localhost' || $mailSmtphost === '127.0.0.1') { | ||||||||||||||||||||||||||||||||||||||||||
| $currentStreamingOptions = $stream->getStreamOptions(); | ||||||||||||||||||||||||||||||||||||||||||
| $currentStreamingOptions = array_merge_recursive($currentStreamingOptions, array( | ||||||||||||||||||||||||||||||||||||||||||
| 'ssl' => array( | ||||||||||||||||||||||||||||||||||||||||||
| 'allow_self_signed' => true, | ||||||||||||||||||||||||||||||||||||||||||
| 'verify_peer' => false, | ||||||||||||||||||||||||||||||||||||||||||
| 'verify_peer_name' => false | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| )); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+310
to
+318
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm of two minds here - one is that it indeed makes localhosts work without any setup, which, as you stated has confused many users due to how the Symfony Mailer works. OTOH I'm not entirely happy with overwriting config options per default. I think there's some middle ground here: check if the I also think it doesn't need to be an elseif but can be an if condition on it's own. Something like:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| /** @psalm-suppress InternalMethod */ | ||||||||||||||||||||||||||||||||||||||||||
| $stream->setStreamOptions($currentStreamingOptions); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory we could even do this if no valid host was provided, e.g. by using such a filter: https://github.com/nextcloud/all-in-one/blob/c9b97220d0175914c3ee8c7199949376f7bfe3b0/php/src/Data/ConfigurationManager.php#L274-L295
However this sounds like magic and not sure if we want to actually do this automatically.
WDYT @nextcloud/server-backend @miaulalala