From ceb1c87af7a2b109c88a196af496cb716ea7e4fa Mon Sep 17 00:00:00 2001 From: adrien Date: Wed, 19 Aug 2020 17:22:02 +0200 Subject: [PATCH] fix(SSL): Enable server hostname verification --- .../bonitasoft/connectors/email/EmailConnector.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/bonitasoft/connectors/email/EmailConnector.java b/src/main/java/org/bonitasoft/connectors/email/EmailConnector.java index 3407bc7..b965deb 100644 --- a/src/main/java/org/bonitasoft/connectors/email/EmailConnector.java +++ b/src/main/java/org/bonitasoft/connectors/email/EmailConnector.java @@ -37,7 +37,6 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMessage.RecipientType; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeUtility; import javax.mail.util.ByteArrayDataSource; @@ -151,7 +150,7 @@ public class EmailConnector extends AbstractConnector { public void validateInputParameters() throws ConnectorValidationException { // FIXME: handle replyTo parameter (not implemented yet): logInputParameters(); - List errors = new ArrayList(1); + List errors = new ArrayList<>(1); final Integer smtpPort = (Integer) getInputParameter(SMTP_PORT); if (smtpPort == null) { @@ -171,7 +170,7 @@ public void validateInputParameters() throws ConnectorValidationException { final String from = (String) getInputParameter(FROM); checkInputParameter(from, errors); - + final String returnPath = (String) getInputParameter(RETURN_PATH); checkInputParameter(from, errors); @@ -282,6 +281,7 @@ private Session getSession() { // Using SSL if ((Boolean) getInputParameter(SSL_SUPPORT, true)) { properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); + properties.put("mail.smtp.ssl.checkserveridentity", "true"); properties.put("mail.smtp.socketFactory.fallback", "false"); properties.put("mail.smtp.socketFactory.port", smtpPort); } @@ -300,7 +300,7 @@ private Session getSession() { private Map getHeaders() { final List> headersList = (List>) getInputParameter(HEADERS); - final Map headers = new HashMap(); + final Map headers = new HashMap<>(); if (headersList != null) { for (List rows : headersList) { if (rows.size() == 2) { @@ -396,7 +396,7 @@ private Multipart getMultipart(final boolean html, final String message, final S StringBuilder messageBody = new StringBuilder(message); ProcessAPI processAPI = getAPIAccessor().getProcessAPI(); final Multipart body = new MimeMultipart("mixed"); - List bodyParts = new ArrayList(); + List bodyParts = new ArrayList<>(); if (attachments != null) { for (Object attachment : attachments) { handleAttachment(html, messageBody, processAPI, bodyParts, attachment);