]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11071 CWE-297 host of SMTP server certificate is not verified
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 20 Jul 2018 21:23:22 +0000 (23:23 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 25 Jul 2018 18:21:19 +0000 (20:21 +0200)
server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java

index ca2236d682c2bbe7d270020fef231a13e74ea368..671a507ac83da68323250400b84f6e43f9cb53df 100644 (file)
@@ -199,6 +199,7 @@ public class EmailNotificationChannel extends NotificationChannel {
   private void configureSecureConnection(SimpleEmail email) {
     if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "ssl")) {
       email.setSSLOnConnect(true);
+      email.setSSLCheckServerIdentity(true);
       email.setSslSmtpPort(String.valueOf(configuration.getSmtpPort()));
 
       // this port is not used except in EmailException message, that's why it's set with the same value than SSL port.
@@ -207,6 +208,7 @@ public class EmailNotificationChannel extends NotificationChannel {
     } else if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "starttls")) {
       email.setStartTLSEnabled(true);
       email.setStartTLSRequired(true);
+      email.setSSLCheckServerIdentity(true);
       email.setSmtpPort(configuration.getSmtpPort());
     } else if (StringUtils.isBlank(configuration.getSecureConnection())) {
       email.setSmtpPort(configuration.getSmtpPort());