I want to read emails from exchange server over IMAP SSL with JavaMail API. I am using the following piece of code.
Properties props =System.getProperties();
props.setProperty("mail.store.protocol","imaps");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("server hostname","username","password");
But I am unable to establish a connection. All I get is following error.
javax.mail.MessagingException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:618) at javax.mail.Service.connect(Service.java:291) at javax.mail.Service.connect(Service.java:172) at
I am not sure if there are any pre-requisite steps to be followed for establishing a connection.
Appreciate your help!