JavaMail on pop3s, and servlets on https
843834Feb 19 2008 — edited Feb 21 2008Greetings.
I'm currently using JavaMail to access my mailbox on gmail.com via pop3s. I'm doing this from a batch program.
The batch is meant to retrieve the messages from the mailbox, and then use the content as a part of a request sent via HTTPS to a servlet.
The same version of the batch, working via pop3 (not pop3s), worked very well and did not give me any kind of problem. During the migration to pop3s, i noticed that i can't connect to the servlet via HTTPS anymore.
the error i get is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
Excerpts from the code that I think might be of interest are:
String sslFactory = "javax.net.ssl.SSLSocketFactory";
props.setProperty("mail.pop3.socketFactory.class", sslFactory);
props.setProperty("mail.pop3.socketFactory.fallback", "false");
props.setProperty("mail.pop3.port", porta);
props.setProperty("mail.pop3.socketFactory.port", porta);
URLName url = new URLName("pop3", server, port, "", userName, password);
props.put("mail.pop3.timeout", timeout);
props.put("mail.pop3.connectiontimeout", timeout);
Session session = Session.getDefaultInstance(props, null);
try {
Store store = new POP3SSLStore(session, url);
store.connect("pop.gmail.com", 995, username, password);
I noticed that the problem comes exactly from the last line (the one in bold). Without it, I have absolutely no problem connecting to the HTTPS servlet, but obviously I can't connect to the mailbox.
Has anyone ever dealt with something like that?
Edited by: Firestart on Feb 19, 2008 2:10 AM