code: private static PrivateKey getPrivateKey(String filename, String password, String key) {
          if(logger.isDebugEnabled()) logger.debug("filename = " + filename + " key = " + key);
          PrivateKey privateKey = null;
  
          try {
              KeyStore keystore = KeyStore.getInstance("JKS");
              keystore.load(Config.getInstance().getInputStreamFromFile(filename),
                      password.toCharArray());
  
              privateKey = (PrivateKey) keystore.getKey(key,
                      password.toCharArray());
          } catch (Exception e) {
              logger.error("Exception:", e);
          }
  
          if (privateKey == null) {
              logger.error("Failed to retrieve private key from keystore");
          }
  
          return privateKey;
      }
docs: Get private key from java key store
  
  @param filename Key store file name
  @param password Key store password
  @param key key name in keystore
  @return A PrivateKey object