Is it possible to make Java ignore the "trust store" and just accept whatever SSL certificate it gets?


vy32:

I'm trying to write an SSL client that sends mail using javax.mail API. The problem I'm having is that the server is requesting me to use SSL, but the server is also configured with a non-standard SSL certificate. The web page I found says I need to install the certificate into the truststore. I don't want to do this (I don't have the necessary permissions.)

  1. Is there a way to make Java ignore the certificate error and accept it?
  2. Failing that, is there a way to make the truststore local to my program instead of installing it across the JVM?
Zed:

You need to create a fake TrustManager to accept all certificates and register it as an administrator. like this:

public class MyManager implements com.sun.net.ssl.X509TrustManager {
  public boolean isClientTrusted(X509Certificate[] chain) { return true; }
  public boolean isHostTrusted(X509Certificate[] chain) { return true; }
  ...
}


com.sun.net.ssl.TrustManager[] managers =
  new com.sun.net.ssl.TrustManager[] {new MyManager()};

com.sun.net.ssl.SSLContext.getInstance("SSL").
       .init(null, managers, new SecureRandom());

Related


Java Webstart Trust Store SSL

SPD: Need some guidance. I have a Java Webstart application and I want it to connect to a server via SSL. Just add a property like: System.setProperty("javax.net.ssl.trustStore", "my.keystore"); however, it doesn't work since the JAWS program is downloading th

Java Webstart Trust Store SSL

SPD: Need some guidance. I have a Java Webstart application and I want it to connect to a server via SSL. Just add a property like: System.setProperty("javax.net.ssl.trustStore", "my.keystore"); however, it doesn't work since the JAWS program is downloading th

How to ignore SSL certificate in Java

JPG: I keep getting this exception "javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject matching IP address xxx.xxx.xx.xxx alternative name exists" on an HTTP GET request. I have tried almost everything. Is there a JVM argu

Ignore SSL certificate errors for Java

andrewpthorp: Apache Http client. You can see the relevant code here : String url = "https://path/to/url/service"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); // Test whether to ignore cert errors if (ignoreCertErrors){ Tr

How to ignore SSL certificate in Java

JPG: I keep getting this exception "javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject matching IP address xxx.xxx.xx.xxx alternative name exists" on an HTTP GET request. I have tried almost everything. Is there a JVM argu

Ignore SSL certificate errors for Java

andrewpthorp: Apache Http client. You can see the relevant code here : String url = "https://path/to/url/service"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); // Test whether to ignore cert errors if (ignoreCertErrors){ Tr

Java and HttpsUrlConnection ignore ssl certificate

Jaraj Jorah 1) I tried to use https url by ignoring ssl certificate 2) I am trying to send a https url request to the Google Geolocation api url, but I am getting a lower response than the response, indicating that I am making the wrong program. Because I trie

How to ignore SSL certificate in Java

JPG: I keep getting this exception "javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject matching IP address xxx.xxx.xx.xxx alternative name exists" on an HTTP GET request. I have tried almost everything. Is there a JVM argu

How to ignore SSL certificate in Java

JPG: I keep getting this exception "javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject matching IP address xxx.xxx.xx.xxx alternative name exists" on an HTTP GET request. I have tried almost everything. Is there a JVM argu

Ignore SSL certificate errors for Java

andrewpthorp: Apache Http client. You can see the relevant code here : String url = "https://path/to/url/service"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); // Test whether to ignore cert errors if (ignoreCertErrors){ Tr

How to make Jersey ignore ssl certificate errors?

Simon bug tracking: javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path

How to add certificate to Android trust store?

scotty 9811 I have a client application designed for Android. Android applications are based on XML and Java, as are our Windows server-side applications. The problem is that since we're using Android now, we have to deal with trust stores. Is there any way to

How to add certificate to Android trust store?

scotty 9811 I have a client application designed for Android. Android applications are based on XML and Java, as are our Windows server-side applications. The problem is that since we're using Android now, we have to deal with trust stores. Is there any way to

Ignore SSL certificate in servlet

Tim: I get the following exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targ

Ignore SSL certificate in servlet

Tim: I get the following exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targ

Ignore SSL certificate in servlet

Tim I get the following exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targe

Ignore SSL certificate in servlet

Tim: I get the following exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targ

How to make Restlet client ignore SSL certificate issues

nwaltham: I'm currently working in a test environment where the server has a default self-signed SSL certificate. I'm using Restlet 2.1-RC2 and instantiating a client resource like this: Client client = new Client(new Context(), Protocol.HTTP); cr = new Client