Created
June 14, 2018 16:12
-
-
Save RevenueGitHubAdmin/325b4f3451529a2cf29c646596e99b5f to your computer and use it in GitHub Desktop.
[JavaScript] 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 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