Home > Net >  What is the purpose of Java key store parameter (javax.net.ssl.keyStore), How to use it?
What is the purpose of Java key store parameter (javax.net.ssl.keyStore), How to use it?

Time:08-31

In order to documentations and samples to use key store in JAVA, we need to specify keystore file and password like below;

KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(new FileInputStream("/path/cert.p12"), properties.getTrustStorePassword().toCharArray());

And there is also one parameter to specify keystore and password:

-Djavax.net.ssl.keyStore=/path/cert.p12; -Djavax.net.ssl.keyStorePassword=123456

if we have to specify keystore file path and password while loading it, what is the point of that system parameter?

How can we use the keystore that specified in system parameter?

Iam able to use it without specifying this system parameter,So what is the effect of it?

What is the correct usage of this parameter?

CodePudding user response:

The system properties can define a default for the entire Java process. If you get the default SSLContext, the system properties are used to obtain key material. These setting can be ignored by creating your own KeyStore instances in code and initializing a new instance of SSLContext; this can be desirable if, for example, you have to connect to a server with a self-signed certificate.

  • Related