Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@RevenueGitHubAdmin
Created June 14, 2018 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RevenueGitHubAdmin/325b4f3451529a2cf29c646596e99b5f to your computer and use it in GitHub Desktop.
Save RevenueGitHubAdmin/325b4f3451529a2cf29c646596e99b5f to your computer and use it in GitHub Desktop.
[JavaScript] How to open the KeyStore.
/*
* The following snippet uses the Forge JavaScript library (https://github.com/digitalbazaar/forge)
* to open the keystore file containing the certificate and key pairs used to sign the requests to be
* sent. The first parameter expected is the absolute path for the keystore to be used. The second
* parameter expected is the MD5 hash of keystore's password, encoded using BASE64. For more information
* about how to use the Forge JavaScript library, please, refer to the aforementioned URL.
*
* 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.
*/
const fs = require('fs');
function openKeyStore(keyStoreFilePath, encodedPassword) {
var asn1 = forge.asn1.fromDer(
fs.readFileSync(keystoreFilePath, 'binary')
);
return forge.pkcs12.pkcs12FromAsn1(asn1, encodedPassword);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment