spyhunter99 / installcert

fork of http://s-n-ushakov.blogspot.com/2013/11/yet-another-installcert-for-java-now.html to use as a library
BSD 3-Clause "New" or "Revised" License
17 stars 11 forks source link

NullPointerException on unsupported protocol #17

Closed skyghis closed 3 years ago

skyghis commented 3 years ago

Exception received :

Exception in thread "main" java.lang.NullPointerException
    at usn.net.ssl.util.InstallCert.getCerts(InstallCert.java:612)
    at usn.net.ssl.util.InstallCert.main(InstallCert.java:376)

Expected exception :

javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]

I have this exception on a ldaps server when I use OpenJdk JRE v11.0.11 The cause of the exception is the removal of TLSv1 and TLSv1.1 (See: TLSv1 and TLSv1.1 Disabled by Default in Java after April 2021).

The thrown SSLHandshakeException have no cause and create a NullPointerException.

spyhunter99 commented 3 years ago

thanks for reporting this. i'll take a look at it

spyhunter99 commented 3 years ago

even if i enable this feature, other java applications will most likely run into the same issue. I guess it's useful for getting the cert and saving it locally for other uses though.

spyhunter99 commented 3 years ago

so i'm not super sure which version of installcert this came off of, but that line is an exception handling line. i'll some null checks on it. Please test retest with your server if possible

skyghis commented 3 years ago

Thanks for the work.

I was not expecting the code to allow import of unsupported ciphers. I only expected to fix the NullPointerException on exception handling to have a valid error message (and find the cause of the import error).

even if i enable this feature, other java applications will most likely run into the same issue.

Exactly. The import is useless in this case.
I personally edited the java.security file when the certificate can't be edited. I think the new enableAll option is useless.

spyhunter99 commented 3 years ago

got it, i rolled back that change. feel free to retest the NPE issue when you have time

skyghis commented 3 years ago

I tested on actual master and I got the expected exception. Thanks.

Could you plan a release please ?

spyhunter99 commented 3 years ago

just did the release, may be a few days before it's available globally on maven central