Skip to content

Commit 41de29e

Browse files
committed
UY-1487 Angus mail requies additional property to disable hostname changing
set is automatically when our custom "trust all hosts" mode is used.
1 parent 5e67bfc commit 41de29e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

engine/src/main/java/pl/edu/icm/unity/engine/notifications/email/EmailChannel.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,28 @@ class EmailChannel implements NotificationChannelInstance
5050
String smtpPassword = props.getProperty(EmailFacility.CFG_PASSWD);
5151
Authenticator smtpAuthn = (smtpUser != null && smtpPassword != null) ?
5252
new SimpleAuthenticator(smtpUser, smtpPassword) : null;
53-
String trustAll = props.getProperty(EmailFacility.CFG_TRUST_ALL);
54-
SSLSocketFactory socketFactory = (trustAll != null && "true".equalsIgnoreCase(trustAll)) ?
53+
boolean trustAllServers = isTrustingAllServers(props);
54+
SSLSocketFactory socketFactory = trustAllServers ?
5555
createTrustAllSocketFactory() : createVerifyingSocketFactory(pkiManagement);
5656
props.put("mail.smtp.ssl.socketFactory", socketFactory);
57+
if (trustAllServers)
58+
props.put("mail.smtp.ssl.checkserveridentity", false);
5759
session = Session.getInstance(props, smtpAuthn);
5860
}
5961

62+
private static boolean isTrustingAllServers(Properties props)
63+
{
64+
String trustAll = props.getProperty(EmailFacility.CFG_TRUST_ALL);
65+
return (trustAll != null && "true".equalsIgnoreCase(trustAll));
66+
}
67+
6068
private SSLSocketFactory createTrustAllSocketFactory()
6169
{
6270
MailSSLSocketFactory trustAllSF;
6371
try
6472
{
6573
trustAllSF = new MailSSLSocketFactory();
74+
//trustAllSF.setTrustManagers(new CommonX509TrustManager(new BinaryCertChainValidator(true)));
6675
} catch (GeneralSecurityException e)
6776
{
6877
//really shouldn't happen
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/MYmail.properties
22
/MYsms.properties
33
/MYremoteOAuth.properties
4+
/MYmail-furms.properties

0 commit comments

Comments
 (0)