-
Notifications
You must be signed in to change notification settings - Fork 253
Description
SMTP has a bug introduced by 579c6ab
After trying out PWM 2.0 (master branch) with 1.9 config, SMTP started failing. Then I went on and investigated.
In 2.0 there was introduced two more options for SMTP configuration which are SMTPS (SMTP over SSL/TLS) and StartTLS (Plain SMTP with STARTTLS). But after trying everyone of them, I found out that the new StartTLS option does not work and plain SMTP does not use advanced settings anymore. We used StartTLS for over 3 years through advanced settings (mail.smtp.starttls.enable=true).
I went further and checked the code.
The following lines set SSL even if using StartTLS, which is wrong:
pwm/server/src/main/java/password/pwm/svc/email/EmailServerUtil.java
Lines 175 to 187 in 57528e4
final MailSSLSocketFactory mailSSLSocketFactory = new MailSSLSocketFactory(); | |
mailSSLSocketFactory.setTrustManagers( trustManager ); | |
properties.put( "mail.smtp.ssl.enable", true ); | |
properties.put( "mail.smtp.ssl.checkserveridentity", true ); | |
properties.put( "mail.smtp.socketFactory.fallback", false ); | |
properties.put( "mail.smtp.ssl.socketFactory", mailSSLSocketFactory ); | |
properties.put( "mail.smtp.ssl.socketFactory.port", port ); | |
final boolean useStartTls = smtpServerType == SmtpServerType.START_TLS; | |
properties.put( "mail.smtp.starttls.enable", useStartTls ); | |
properties.put( "mail.smtp.starttls.required", useStartTls ); |
Also, the following is returning properties before putting advanced settings if using plain SMTP:
pwm/server/src/main/java/password/pwm/svc/email/EmailServerUtil.java
Lines 171 to 174 in 820882b
if ( smtpServerType == SmtpServerType.SMTP ) | |
{ | |
return properties; | |
} |
So basically, the only working options are plain SMTP without advanced settings and SMTPS.
I proposed the PR #494 for this in July and it's still hanging without a comment. It fix the problem and does not conflict, so why not merge and fix this once and for all?