Disable trusted certificate validation in POP3S
843834Apr 17 2008 — edited Apr 17 2008Hi
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