When you create a Properties
object using new Properties()
, you don't have any data stored in that object yet. So it doesn't make sense to do properties.getProperty("PRIVATE")
because that will always return null
.
You claim that you've made a .properties
file, but I don't see you loading into the Properties
object anywhere:
properties.load(new FileInputStream(readerForProperties));
Whichever properties you've defined in the .properties
file (see API documentation to find out how to create such a file) using a Reader
that can read that file, will now be accessible using the getProperty()
method.
You are using the path
variable to create a FileInputStream
that is used to load a KeyStore
. In that case, path needs to be the path to your key store.
It seems as if you copy/pasted an example I've written without reading (or at least: without understanding) the documentation.
In my example, I used "Private"
as property name, but that's irrelevant. If you prefer naming it "pathToKS"
or "keystore"
or even "banana"
, you can do so.
In my case, my .properties
file looks like this:
PUBLIC c:/examples/signatures/public.cer
ROOTCERT c:/examples/signatures/CACertSigningAuthority.crt
PRIVATE c:/examples/signatures/private.p12
PASSWORD secret
So in my case, properties.getProperty("PRIVATE")
will return my keystore, properties.getProperty("PUBLIC")
will return my public key, properties.getProperty("ROOTCERT")
will return the public key of a Certificate Authority and properties.getProperty("PASSWORD")
will return my password for the keystore and for the private key stored in the keystore corresponding with my public key (these password needn't be identical).
If you prefer to store your path to the keystore like this:
banana c:/examples/signatures/private.p12
You'll need to do this:
String path = properties.getProperty("banana");
Please read the documentation carefully before writing more code. Reading the documentation will save you plenty of time.