Browse Source

Explicitly decide whether to use TLS in mailer's configuration (#5024)

* explicitly decide on using TLS for mail connections

* explicitly decide on using TLS for mail connections

* keep compatibility
tags/v1.7.0-dev
Lanre Adelowo 5 years ago
parent
commit
3a1ed82529

+ 2
- 0
custom/conf/app.ini.sample View File

USE_CERTIFICATE = false USE_CERTIFICATE = false
CERT_FILE = custom/mailer/cert.pem CERT_FILE = custom/mailer/cert.pem
KEY_FILE = custom/mailer/key.pem KEY_FILE = custom/mailer/key.pem
; Should SMTP connection use TLS
IS_TLS_ENABLED = false
; Mail from address, RFC 5322. This can be just an email address, or the `"Name" <email@example.com>` format ; Mail from address, RFC 5322. This can be just an email address, or the `"Name" <email@example.com>` format
FROM = FROM =
; Mailer user name and password ; Mailer user name and password

+ 4
- 3
docs/content/doc/advanced/config-cheat-sheet.en-us.md View File

HTTP protocol. HTTP protocol.
- `USE_COMPAT_SSH_URI`: **false**: Force ssh:// clone url instead of scp-style uri when - `USE_COMPAT_SSH_URI`: **false**: Force ssh:// clone url instead of scp-style uri when
default SSH port is used. default SSH port is used.
### Repository - Pull Request (`repository.pull-request`) ### Repository - Pull Request (`repository.pull-request`)
- `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: List of prefixes used in Pull Request - `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: List of prefixes used in Pull Request
title to mark them as Work In Progress title to mark them as Work In Progress
`FROM` and `SENDMAIL_PATH`. `FROM` and `SENDMAIL_PATH`.
- `SENDMAIL_PATH`: **sendmail**: The location of sendmail on the operating system (can be - `SENDMAIL_PATH`: **sendmail**: The location of sendmail on the operating system (can be
command or full path). command or full path).
- ``IS_TLS_ENABLED`` : **false** : Decide if SMTP connections should use TLS.


## Cache (`cache`) ## Cache (`cache`)


- `TOKEN`: **\<empty\>**: You need to specify the token, if you want to include in the authorization the metrics . The same token need to be used in prometheus parameters `bearer_token` or `bearer_token_file`. - `TOKEN`: **\<empty\>**: You need to specify the token, if you want to include in the authorization the metrics . The same token need to be used in prometheus parameters `bearer_token` or `bearer_token_file`.


## API (`api`) ## API (`api`)
- `ENABLE_SWAGGER_ENDPOINT`: **true**: Enables /api/swagger, /api/v1/swagger etc. endpoints. True or false; default is true.
- `ENABLE_SWAGGER_ENDPOINT`: **true**: Enables /api/swagger, /api/v1/swagger etc. endpoints. True or false; default is true.
- `MAX_RESPONSE_ITEMS`: **50**: Max number of items in a page. - `MAX_RESPONSE_ITEMS`: **50**: Max number of items in a page.


## i18n (`i18n`) ## i18n (`i18n`)

+ 2
- 3
modules/mailer/mailer.go View File

} }
defer conn.Close() defer conn.Close()


isSecureConn := false
isSecureConn := opts.IsTLSEnabled || (strings.HasSuffix(port, "465"))
// Start TLS directly if the port ends with 465 (SMTPS protocol) // Start TLS directly if the port ends with 465 (SMTPS protocol)
if strings.HasSuffix(port, "465") {
if isSecureConn {
conn = tls.Client(conn, tlsconfig) conn = tls.Client(conn, tlsconfig)
isSecureConn = true
} }


client, err := smtp.NewClient(conn, host) client, err := smtp.NewClient(conn, host)

+ 2
- 0
modules/setting/setting.go View File

SkipVerify bool SkipVerify bool
UseCertificate bool UseCertificate bool
CertFile, KeyFile string CertFile, KeyFile string
IsTLSEnabled bool


// Sendmail sender // Sendmail sender
UseSendmail bool UseSendmail bool
UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(), UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
CertFile: sec.Key("CERT_FILE").String(), CertFile: sec.Key("CERT_FILE").String(),
KeyFile: sec.Key("KEY_FILE").String(), KeyFile: sec.Key("KEY_FILE").String(),
IsTLSEnabled: sec.Key("IS_TLS_ENABLED").MustBool(),


UseSendmail: sec.Key("USE_SENDMAIL").MustBool(), UseSendmail: sec.Key("USE_SENDMAIL").MustBool(),
SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"), SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"),

Loading…
Cancel
Save