https://github.com/vanioinformatika/node-simple-keystore
Simple keystore for Node.js
https://github.com/vanioinformatika/node-simple-keystore
Last synced: 6 months ago
JSON representation
Simple keystore for Node.js
- Host: GitHub
- URL: https://github.com/vanioinformatika/node-simple-keystore
- Owner: vanioinformatika
- License: mit
- Created: 2017-04-11T08:30:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T05:49:28.000Z (almost 3 years ago)
- Last Synced: 2025-03-24T10:19:20.902Z (7 months ago)
- Language: TypeScript
- Size: 366 KB
- Stars: 2
- Watchers: 7
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/vanioinformatika/node-simple-keystore)
# Simple filesystem based keystore for Node.js
Simple filesystem keystore implementation
# Usage
```javascript
const {Keystore, KeystoreReaderFs} = require('@vanioinformatika/simple-keystore')// initializing keystore
const baseDir = ''
const refreshIntervalMillis = 30 * 1000 // 30 secs
const signingKeyPassphrases = { // an object containing passphrases for private keys
'key_id_1': 'passphrase1',
'key_id_2': 'passphrase2'
}
const keystoreReader = new KeystoreReaderFs(baseDir)
const keystore = new Keystore(signingKeyPassphrases, keystoreReader)// start reading keystore periodically
keystore.start(refreshIntervalMillis)...
// publishing public keys with express.js
router.route('/certs').get((req, res) => {
const certificateList = keystore.fny.getAllCertificatesAsJWKS()
res.status(HttpStatus.OK).json({keys: certificateList})
})
```The keys directory has to contain the following files:
```
rootCA.cert.pem
{keyId}.privkey.pem
{keyId}.cert.pem
```
The `rootCA.cert.pem` contains the certificate of the CA that issued the certificates.
All other files that end with `.privkey.pem` and `.cert.pem` are the private keys and certificates for a given key id.