Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SSL): Enable server hostname verification #8

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -151,7 +150,7 @@ public class EmailConnector extends AbstractConnector {
public void validateInputParameters() throws ConnectorValidationException {
// FIXME: handle replyTo parameter (not implemented yet):
logInputParameters();
List<String> errors = new ArrayList<String>(1);
List<String> errors = new ArrayList<>(1);
final Integer smtpPort = (Integer) getInputParameter(SMTP_PORT);

if (smtpPort == null) {
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}
Expand All @@ -300,7 +300,7 @@ private Session getSession() {

private Map<String, String> getHeaders() {
final List<List<Object>> headersList = (List<List<Object>>) getInputParameter(HEADERS);
final Map<String, String> headers = new HashMap<String, String>();
final Map<String, String> headers = new HashMap<>();
if (headersList != null) {
for (List<Object> rows : headersList) {
if (rows.size() == 2) {
Expand Down Expand Up @@ -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<MimeBodyPart> bodyParts = new ArrayList<MimeBodyPart>();
List<MimeBodyPart> bodyParts = new ArrayList<>();
if (attachments != null) {
for (Object attachment : attachments) {
handleAttachment(html, messageBody, processAPI, bodyParts, attachment);
Expand Down