How can I simulate the behavior of curl -k <url> in Java?
-
I'm trying to poll a HTTPS URL on a local server, but cannot due to security certificate issues. If I try to 'curl' it on CLI, still it would complain. See here: However, on CLI I can successfully get the content if I use curl with -k option. The code I'm currently using is: HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); InputStream is = connection.getInputStream(); How can I change this so it would fetch it 'insecurly', like curl does with -k option?
-
Answer:
You can use SSLSocketFactory in connection with HTTPSURLConnection as described here http://stackoverflow.com/questions/859111/how-do-i-accept-a-self-signed-certificate-with-a-java-httpsurlconnection
Asher Syed at Quora Visit the source
Related Q & A:
- How can I make a Spinner only by java?Best solution by stackoverflow.com
- How can I mount a network drive in Mac OS X in Java?Best solution by Stack Overflow
- How can I change url name?Best solution by Yahoo! Answers
- how can I listen for database changes using java?Best solution by Stack Overflow
- How can I make a quick $60?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.