Skip to content

Commit 73cb639

Browse files
pbe-axelorsolidnerd
authored andcommitted
Add S/MIME Email Signing (sameersbn#2009)
* Add S/MIME Email Signing See https://docs.gitlab.com/ce/administration/smime_signing_email.html Signed-off-by: Pierre Belloy <p.belloy@axelor.com> * Remove s/mime email configs if not enabled Signed-off-by: Pierre Belloy <p.belloy@axelor.com>
1 parent ea1fce2 commit 73cb639

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ Below is the complete list of available options that can be used to customize yo
772772
| `GITLAB_EMAIL_REPLY_TO` | The reply-to address of emails sent out by GitLab. Defaults to value of `GITLAB_EMAIL`, else defaults to `noreply@example.com`. |
773773
| `GITLAB_EMAIL_SUBJECT_SUFFIX` | The e-mail subject suffix used in e-mails sent by GitLab. No defaults. |
774774
| `GITLAB_EMAIL_ENABLED` | Enable or disable gitlab mailer. Defaults to the `SMTP_ENABLED` configuration. |
775+
| `GITLAB_EMAIL_SMIME_ENABLE` | Enable or disable email S/MIME signing. Defaults is `false`. |
776+
| `GITLAB_EMAIL_SMIME_KEY_FILE` | Specifies the path to a S/MIME private key file in PEM format, unencrypted. Defaults to ``. |
777+
| `GITLAB_EMAIL_SMIME_CERT_FILE` | Specifies the path to a S/MIME public certificate key in PEM format. Defaults to ``. |
775778
| `GITLAB_DEFAULT_THEME` | Default theme ID, by default 2. (1 - Indigo, 2 - Dark, 3 - Light, 4 - Blue, 5 - Green, 6 - Light Indigo, 7 - Light Blue, 8 - Light Green, 9 - Red, 10 - Light Red) |
776779
| `GITLAB_INCOMING_EMAIL_ADDRESS` | The incoming email address for reply by email. Defaults to the value of `IMAP_USER`, else defaults to `reply@example.com`. Please read the [reply by email](http://doc.gitlab.com/ce/incoming_email/README.html) documentation to currently set this parameter. |
777780
| `GITLAB_INCOMING_EMAIL_ENABLED` | Enable or disable gitlab reply by email feature. Defaults to the value of `IMAP_ENABLED`. |

assets/runtime/config/gitlabhq/gitlab.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ production: &base
7070
email_display_name: {{GITLAB_EMAIL_DISPLAY_NAME}}
7171
email_reply_to: {{GITLAB_EMAIL_REPLY_TO}}
7272
email_subject_suffix: '{{GITLAB_EMAIL_SUBJECT_SUFFIX}}'
73+
#start-email-smime
74+
email_smime:
75+
# Uncomment and set to true if you need to enable email S/MIME signing (default: false)
76+
enabled: {{GITLAB_EMAIL_SMIME_ENABLE}}
77+
# S/MIME private key file in PEM format, unencrypted
78+
# Default is '.gitlab_smime_key' relative to Rails.root (i.e. root of the GitLab app).
79+
key_file: {{GITLAB_EMAIL_SMIME_KEY_FILE}}
80+
# S/MIME public certificate key in PEM format, will be attached to signed messages
81+
# Default is '.gitlab_smime_cert' relative to Rails.root (i.e. root of the GitLab app).
82+
cert_file: {{GITLAB_EMAIL_SMIME_CERT_FILE}}
83+
#end-email-smime
7384

7485
# Email server smtp settings are in config/initializers/smtp_settings.rb.sample
7586

assets/runtime/env-defaults

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ GITLAB_EMAIL_SUBJECT_SUFFIX=${GITLAB_EMAIL_SUBJECT_SUFFIX:-}
283283
GITLAB_EMAIL=${GITLAB_EMAIL:-example@example.com}
284284
GITLAB_EMAIL_REPLY_TO=${GITLAB_EMAIL_REPLY_TO:-noreply@example.com}
285285
GITLAB_EMAIL_DISPLAY_NAME=${GITLAB_EMAIL_DISPLAY_NAME:-GitLab}
286+
GITLAB_EMAIL_SMIME_ENABLE=${GITLAB_EMAIL_SMIME_ENABLE:-false}
287+
GITLAB_EMAIL_SMIME_KEY_FILE=${GITLAB_EMAIL_SMIME_KEY_FILE:-}
288+
GITLAB_EMAIL_SMIME_CERT_FILE=${GITLAB_EMAIL_SMIME_CERT_FILE:-}
286289

287290
## INCOMING MAIL
288291
IMAP_HOST=${IMAP_HOST:-imap.gmail.com}

assets/runtime/functions

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ gitlab_finalize_database_parameters() {
125125
DB_USER=${DB_USER:-${POSTGRESQL_ENV_USER}}
126126
DB_PASS=${DB_PASS:-${POSTGRESQL_ENV_PASS}}
127127
DB_NAME=${DB_NAME:-${POSTGRESQL_ENV_DB}}
128-
128+
129129

130130
if [[ -z ${DB_HOST} ]]; then
131131
echo
@@ -351,6 +351,17 @@ gitlab_configure_mail_delivery() {
351351
GITLAB_EMAIL_DISPLAY_NAME \
352352
GITLAB_EMAIL_REPLY_TO \
353353
GITLAB_EMAIL_SUBJECT_SUFFIX
354+
355+
if [[ ${GITLAB_EMAIL_SMIME_ENABLE} == true ]]; then
356+
exec_as_git sed -i "/#start-email-smime/d" ${GITLAB_CONFIG}
357+
exec_as_git sed -i "/#end-email-smime/d" ${GITLAB_CONFIG}
358+
update_template ${GITLAB_CONFIG} \
359+
GITLAB_EMAIL_SMIME_ENABLE \
360+
GITLAB_EMAIL_SMIME_KEY_FILE \
361+
GITLAB_EMAIL_SMIME_CERT_FILE
362+
else
363+
exec_as_git sed -i "/#start-email-smime/,/#end-email-smime/d" ${GITLAB_CONFIG}
364+
fi
354365
}
355366

356367
gitlab_configure_mailroom() {

0 commit comments

Comments
 (0)