Skip to content

Instantly share code, notes, and snippets.

@RevenueGitHubAdmin
Created June 14, 2018 16:07
Show Gist options
  • Save RevenueGitHubAdmin/476bb3b710f328f658a229b1de53687e to your computer and use it in GitHub Desktop.
Save RevenueGitHubAdmin/476bb3b710f328f658a229b1de53687e to your computer and use it in GitHub Desktop.
[Java] How to open the KeyStore.
/*
* 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;
}
@ljsargent
Copy link

returned keystore variable name should be camel case "keyStore"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment