Skip to content

Commit

Permalink
add tls 1.1 and 1.2 option
Browse files Browse the repository at this point in the history
  • Loading branch information
aynsix committed Oct 2, 2023
1 parent 8f66d7e commit 4321d0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions lib/Alchemy/Phrasea/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,16 @@ private function setupSwiftMailer()
);

$encryption = null;
$secureMode = '';

if (in_array($app['conf']->get(['registry', 'email', 'smtp-secure-mode']), ['ssl', 'tls'])) {
$encryption = $app['conf']->get(['registry', 'email', 'smtp-secure-mode']);
if (in_array($app['conf']->get(['registry', 'email', 'smtp-secure-mode']), ['ssl', 'tlsv1.1', 'tlsv1.2'])) {
$secureMode = $app['conf']->get(['registry', 'email', 'smtp-secure-mode']);

if ($secureMode == 'ssl') {
$encryption = 'ssl';
} else {
$encryption = 'tls';
}
}

$options = $app['swiftmailer.options'] = array_replace([
Expand All @@ -707,7 +714,7 @@ private function setupSwiftMailer()
$transport->setEncryption($options['encryption']);

if ($options['encryption'] == 'tls') {
$transport->setStreamOptions(['ssl' =>['tlsv1.2' => true]]);
$transport->setStreamOptions(['ssl' =>[$secureMode => true]]);
}

if ($app['conf']->get(['registry', 'email', 'smtp-auth-enabled'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private function getDefaultData(array $config)
'smtp-auth-enabled' => false,
'smtp-host' => null,
'smtp-port' => null,
'smtp-secure-mode' => 'tls',
'smtp-secure-mode' => 'tlsv1.1',
'smtp-user' => null,
'smtp-password' => isset($config['email']['smtp-password']) ? $config['email']['smtp-password'] : null,
],
Expand Down
2 changes: 1 addition & 1 deletion lib/Alchemy/Phrasea/Form/Configuration/EmailFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]);
$builder->add('smtp-secure-mode', ChoiceType::class, [
'label' => 'SMTP encryption',
'choices' => ['none' => 'None', 'ssl' => 'SSL', 'tls' => 'TLS'],
'choices' => ['none' => 'None', 'ssl' => 'SSL', 'tlsv1.1' => 'TLS1.1', 'tlsv1.2' => 'TLS1.2'],
]);
$builder->add('smtp-user', TextType::class, [
'label' => 'SMTP user',
Expand Down

0 comments on commit 4321d0e

Please sign in to comment.