2

I have written some code in Java using the java.net.URL class for reading content from a URL. Using java net URL connection.
The URL is a secured URL (https).
For now, I have used the suggestion in this answer Dissable SSL Verification.

I have noticed that when I invoke certain URLs, I can get the response page, but for certain URLs (especially) ones related to security (user lists, group lists, etc...) I get only a blank response; I get a return code of 200 (Success) though.

When I invoke these URLs from the browser (Chrome, FireFox), I get a warning that the server is using a self-signed certificate. Add Exception Page

I can Add an Exception to the browser and continue to the URL where I see the actual page (All URLs).

How do I simulate the Browser's 'Add Exception' in Java?

The answer suggested here telling-java-to-accept-self-signed-ssl-certificate, did not work for me. The answer does not explain how things work in the browser. My question is how do these URLs work in a browser after creating an exception. How do I create/simulate a browser like exception?

Community
  • 1
  • 1
A j
  • 909
  • 1
  • 14
  • 24
  • Possible duplicate of [telling java to accept self-signed ssl certificate](http://stackoverflow.com/questions/2893819/telling-java-to-accept-self-signed-ssl-certificate) – Mario Santini Oct 11 '16 at 08:53
  • Java uses a truststore where it keeps root certificates of CAs (Certificate Authorities). They are required in order to validate if a certain certificate is valid or not. Self signed certificates are not signed by one of these CAs and therefore cannot be validated. A browser can ask the user if she still wants to trust the certificate. What you can do in Java is to add the root certificate to your trust store (works on a server) or otherwise add it dynamically with something like this: http://stackoverflow.com/questions/6755180/java-ssl-connect-add-server-cert-to-keystore-programatically?rq=1 – Sky Oct 11 '16 at 12:02
  • Try to follow the step I mentioned here-http://stackoverflow.com/questions/40467460/firefox-error-your-connection-is-not-secure-while-launching-driver-with-selen/40882513#40882513 – Shoaib Akhtar Nov 30 '16 at 07:46

0 Answers0