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!

Disable trusted certificate validation in POP3S

843834Apr 17 2008 — edited Apr 17 2008
Hi

I am New to JavaMail.

When I run the msgshow .java from JavaMail Demo Program.
for gmail pop3s
------------------------
java msgshow -D -T pop3s -H pop.gmail.com -U user -P passwd

I could able receive mail without any Exception. But Other Host I gave like this java msgshow -D -T pop3s -H xxxxx.com -U user -P passwd..

This is throwing the Exception..

Exception is like "no trusted certificate found"
But I dont want Verify that certificate.
For that I included Following code in msgshow.java
************************************************************************************************
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};

// Install the all-trusting trust manager
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
}

// Now you can access an https URL without having the certificate in the truststore
try {
URL url = new URL("https://hostname/index.html");
} catch (MalformedURLException e) {
}

**********************************************************************************************************
Which above code has been added for Disable trusted certificate validation.
But that is for HTTPS.
I want to Disable trusted certificate validation for pop3s protocol.
Make above code to work what i have to do?
Is there any sample code for that.?
Please suggest me.
I am struggling for one day for find it through google?
Please help me.
Advance Thank you.

By
Lingam
Is there any code
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2008
Added on Apr 17 2008
1 comment
227 views