KEYCLOAK-2362 NPE if SSL certificate is not trusted by Java's default keystore
This commit is contained in:
parent
b93deddda3
commit
4f890e8f2e
1 changed files with 7 additions and 3 deletions
|
@ -15,6 +15,7 @@ import javax.mail.internet.InternetAddress;
|
|||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
|
@ -113,9 +114,12 @@ public class DefaultEmailSenderProvider implements EmailSenderProvider {
|
|||
|
||||
JSSETruststoreConfigurator configurator = new JSSETruststoreConfigurator(session);
|
||||
|
||||
props.put("mail.smtp.ssl.socketFactory", configurator.getSSLSocketFactory());
|
||||
if (configurator.getProvider().getPolicy() == HostnameVerificationPolicy.ANY) {
|
||||
props.setProperty("mail.smtp.ssl.trust", "*");
|
||||
SSLSocketFactory factory = configurator.getSSLSocketFactory();
|
||||
if (factory != null) {
|
||||
props.put("mail.smtp.ssl.socketFactory", factory);
|
||||
if (configurator.getProvider().getPolicy() == HostnameVerificationPolicy.ANY) {
|
||||
props.setProperty("mail.smtp.ssl.trust", "*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue