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 ; }
Get private key from java key store