Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add new $g_email_smime_enable setting
This allows calling PHPMailer::sign() only if necessary, and avoids
4 unnecessary config_get_global() calls if not.

Fixes #25764
  • Loading branch information
dregad committed Jan 8, 2021
1 parent cb13a04 commit e09ea35
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
11 changes: 9 additions & 2 deletions config_defaults_inc.php
Expand Up @@ -756,6 +756,13 @@
*/
$g_email_dkim_identity = 'noreply@example.com';

/**
* Enable S/MIME signature.
*
* @global integer $g_email_smime_enable
*/
$g_email_smime_enable = OFF;

/**
* Path to the S/MIME certificate.
*
Expand Down Expand Up @@ -4368,8 +4375,8 @@
'ldap_server', 'ldap_root_dn', 'ldap_organization', 'ldap_protocol_version',
'ldap_network_timeout', 'ldap_follow_referrals', 'ldap_bind_dn', 'ldap_bind_passwd',
'ldap_uid_field', 'ldap_realname_field', 'use_ldap_realname', 'use_ldap_email',
'email_smime_cert_file', 'email_smime_key_file', 'email_smime_key_password',
'email_smime_extracerts_file',
'email_smime_enable', 'email_smime_cert_file', 'email_smime_key_file',
'email_smime_key_password', 'email_smime_extracerts_file',
);

/**
Expand Down
14 changes: 8 additions & 6 deletions core/email_api.php
Expand Up @@ -1336,12 +1336,14 @@ function email_send( EmailData $p_email_data ) {
}

# S/MIME signature
$t_mail->sign(
config_get_global( 'email_smime_cert_file' ),
config_get_global( 'email_smime_key_file' ),
config_get_global( 'email_smime_key_password' ),
config_get_global( 'email_smime_extracerts_file' )
);
if( ON == config_get_global( 'email_smime_enable' ) ) {
$t_mail->sign(
config_get_global( 'email_smime_cert_file' ),
config_get_global( 'email_smime_key_file' ),
config_get_global( 'email_smime_key_password' ),
config_get_global( 'email_smime_extracerts_file' )
);
}

#apply DKIM settings
if( config_get( 'email_dkim_enable' ) ) {
Expand Down
18 changes: 14 additions & 4 deletions docbook/Admin_Guide/en-US/config/email.xml
Expand Up @@ -558,14 +558,24 @@ $g_notify_flags['new'] = array(
<section id="admin.config.email.smime">
<title>S/MIME signature</title>

<para>This sections describes the necessary settings to enable
<ulink url="https://en.wikipedia.org/wiki/S/MIME">S/MIME</ulink>
signature for outgoing MantisBT e-mails.
</para>

<variablelist>
<varlistentry>
<term>$g_email_smime_cert_file</term>
<term>$g_email_smime_enable</term>
<listitem>
<para>Path to the
<ulink url="https://en.wikipedia.org/wiki/S/MIME">S/MIME</ulink>
certificate.
<para>Enables S/MIME signature.
</para>
<para>Defaults to OFF.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_email_smime_cert_file</term>
<listitem>
<para>Path to the S/MIME certificate.</para>
<para>The file must contain a
<ulink url="https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail">PEM-encoded</ulink>
certificate.
Expand Down

0 comments on commit e09ea35

Please sign in to comment.