Reputation: 3046
When I execute the following code:
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(null, null);
and then the subsequent establishment of the ssl connection, I get a Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
and not a NullPointerException or something. Which keystore is used then? Or is the NPE hidden?
Upvotes: 2
Views: 1916
Reputation: 122719
When null
is used as the keystore argument of KeyManagerFactory.init(..., ...)
, no keystore is used (it's in fact using an empty list internally).
There's no "hidden" NullPointerException
as such, and there's no reason why there should be one. Of course, using a null
value here and an empty collection has consequences when trying to use a keymanager, but not all SSL/TLS connections require a keystore (e.g. client-side without client certificate or anonymous cipher suites).
(Note that, although there is no default value for the keystore, there is one for the truststore, so that default value would be used with TrustManagerFactory.init(null)
.)
Upvotes: 6