Hi All,
I am trying to connect to a mail server which is configured for POP3 access using SSL/TLS and cleartext login.
I have tried using the following code:
public void connect() {
try {
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, new MailAuthenticator());
store = session.getStore("pop3s");
store.connect(popServer, popPort, popUser, popPassword);
folder = store.getDefaultFolder();
if (folder == null) {
throw new Exception("No default folder");
}
folder = folder.getFolder("INBOX");
if (folder == null) {
throw new Exception("No POP3 INBOX");
}
folder.open(Folder.READ_ONLY);
} catch (Exception ex) {
ex.printStackTrace();
}
}
private class MailAuthenticator extends Authenticator{
MailAuthenticator(){
super();
}
}
But this just brings back the error:
javax.mail.MessagingException: Connect failed;
nested exception is: javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at
com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148) at
javax.mail.Service.connect(Service.java:275) at
EMail.Pop3Retreiver.connect(Pop3Retreiver.java:128)
I have installed a certificate using the java keytool and the certificate is visible when you go to control panel and java|security.
Any ideas what i'm missing here as i have read the SSLNotes.txt and can't seem to get any further on this.
Help is appreciated.
Regards