Greetings,
I'm currently trying to connect to an email folder via pop3s using javamail API.
I have no problem doing so with this simple code:
props.put("mail.pop3s.timeout", timeout);
props.put("mail.pop3s.connectiontimeout", timeout);
session = Session.getDefaultInstance(props, null);
store = session.getStore("pop3s");
store.connect(server, port, userName, password);
debugLogger.debug("connected");
folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
but this does work only for gmail, as it's certificate is already trusted in the cacerts of my JVM.
Problem is: my program must be able to connect to "any" pop3s folder. So, I thought I just could try removing the cacerts file from the /lib/security directory of my jre, thus ensuring that no "external" certificates will come in my way.
This worked, making it impossible to connect to gmail (javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found) unless I "tell" my program to trust the certificate from gmail itself.
I already have a truststore containg the trustedCertEntry for gmail.com, but I don't see any way to tell the program to use it... I guess it's just a matter of setting some more props before connecting, but I can't find any documentation on how to do so, the names of the props I should use, and so on...
any help?