java - how to create a properties file for keystore? -
i have created key store , extracted public key. in order use key store i've created keyproperties.properties
file, i'm not sure property called "private". i'm totally confused whether path or private key password or else.
- properties file ->
.properties
extension - data not coming anywhere , i'm using static data.
- private-> path of keystore used private key
this snippet of code:
public static void main(string[] args)throws exception { properties properties = new properties(); string path = properties.getproperty("private"); keystore ks = keystore.getinstance("pkcs12", "bc"); ks.load(new fileinputstream(path), keystore_password.tochararray()); }
when create properties
object using new properties()
, don't have data stored in object yet. doesn't make sense properties.getproperty("private")
because return null
.
you claim you've made .properties
file, don't see loading properties
object anywhere:
properties.load(new fileinputstream(readerforproperties));
whichever properties you've defined in .properties
file (see api documentation find out how create such file) using reader
can read file, accessible using getproperty()
method.
you using path
variable create fileinputstream
used load keystore
. in case, path needs path key store.
it seems if copy/pasted example i've written without reading (or @ least: without understanding) documentation.
in example, used "private"
property name, that's irrelevant. if prefer naming "pathtoks"
or "keystore"
or "banana"
, can so.
in case, .properties
file looks this:
public c:/examples/signatures/public.cer rootcert c:/examples/signatures/cacertsigningauthority.crt private c:/examples/signatures/private.p12 password secret
so in case, properties.getproperty("private")
return keystore, properties.getproperty("public")
return public key, properties.getproperty("rootcert")
return public key of certificate authority , properties.getproperty("password")
return password keystore , private key stored in keystore corresponding public key (these password needn't identical).
if prefer store path keystore this:
banana c:/examples/signatures/private.p12
you'll need this:
string path = properties.getproperty("banana");
please read documentation before writing more code. reading documentation save plenty of time.