Search code examples
webspherekeystoreibm-cloudwebsphere-libertyjks

How to use keystore in Websphere Liberty and in Java?


maybe it dumb question but I couldn't find explanation by googling. There is settings in server.xml file of Websphere Liberty 8.5

 <keyStore id="sampleJKSKeyStore"
      location="MyKeyStoreFile.jks"
      type="JKS" password="myPassword" />

What can I do with this keystore? Can I for example programatically save to and load from PrivateKey / PublicKey which I create by using the following code:

    final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
    keyGen.initialize(1024);
    final KeyPair key = keyGen.generateKeyPair();
    final PrivateKey privateKey1=key.getPrivate();
    final PublicKey publickey1=key.getPublic();

Thank you in advance!


Solution

  • The keystore configuration essentially just tells the Liberty profile runtime where the keystore is and how to get certificates from it. It can then be associated with the httpEndpoint to store the certificates for https. There are other ways it is used by the Liberty runtime, but the usage is by the runtime, not for applications. If you would like to get application access to it you can raise a request for the product to be enhanced here.