Fixed not recognizing cert errors

pull/172/head
M66B 6 years ago
parent 0bb4282e5c
commit df59723f08

@ -59,7 +59,6 @@ import javax.mail.Session;
import javax.mail.Store; import javax.mail.Store;
import javax.mail.event.StoreListener; import javax.mail.event.StoreListener;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
@ -379,12 +378,15 @@ public class MailService implements AutoCloseable {
} else } else
throw new NoSuchProviderException(protocol); throw new NoSuchProviderException(protocol);
} catch (MessagingException ex) { } catch (MessagingException ex) {
if (factory != null && if (factory != null) {
ex.getCause() instanceof SSLHandshakeException && Throwable ce = ex;
ex.getCause().getCause() instanceof CertificateException) while (ce != null) {
throw new UntrustedException(factory.getFingerPrint(), ex); if (ce instanceof CertificateException)
else throw new UntrustedException(factory.getFingerPrint(), ex);
throw ex; ce = ce.getCause();
}
}
throw ex;
} }
} }

Loading…
Cancel
Save