Created
June 14, 2018 16:07
-
-
Save RevenueGitHubAdmin/476bb3b710f328f658a229b1de53687e to your computer and use it in GitHub Desktop.
[Java] How to open the KeyStore.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The following snippet opens an external keystore file and returns it to be used to retrieve | |
* certificates and keys. This is an important step, once that the certificate and the private | |
* key contained in the keystore will be used to sign the requests. | |
* | |
* Gists provided for illustrative purposes only. Developers can use these as a support tool | |
* but the Office of the Revenue Commissioners (Revenue) does not provide any warranty with | |
* these gists. | |
*/ | |
public KeyStore openKeyStore(String filePath, String encodedPassword) throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { | |
KeyStore keyStore = KeyStore.getInstance("PKCS12"); | |
keyStore.load( | |
new FileInputStream(filePath), | |
encodedPassword.toCharArray() | |
); | |
return keystore; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
returned keystore variable name should be camel case "keyStore"