Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pop3S using custom truststore

843834Mar 27 2008 — edited Mar 27 2008
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2008
Added on Mar 27 2008
1 comment
130 views