0

i also want to know how to ignore SSL certificate errors in Apache HttpClient 4.0 ,so i read this post:How to ignore SSL certificate errors in Apache HttpClient 4.0 and do as it say.

but i got an error in intellij idea in this statement:

   SSLContext sslContext = SSLContext.getInstance("SSL");

Unhandle exception:java.security.NoSuchAlgorithmException.

i also tried "TLS" but useless.

Please does anybody know how to solve this issue?

Community
  • 1
  • 1
user2172948
  • 213
  • 3
  • 7

1 Answers1

2

You get this compile error because SSLContext.getInstance("SSL"); throws a checked exception which you have to take care of.

Either by surrounding the line with a try-catch block:

try {
   SSLContext sslContext = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
   /// handle e
}

or add throws NoSuchAlgorithmException to the method definition.

This are Java basics you should learn something about Exceptions: Lesson: Exceptions

Kai
  • 38,985
  • 14
  • 88
  • 103