How to use the node-forge.pki.publicKeyToPem function in node-forge

To help you get started, we’ve selected a few node-forge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Levino / mock-jwks / __tests__ / jwtCreation.ts View on Github external
t.test('should sign a jwt', (assert) => {
    assert.plan(2)
    const keyPair = createKeyPair()
    const jwtPayload = {
      iss: 'SOMETHING',
    }
    const token = signJwt(keyPair.privateKey, jwtPayload)
    assert.ok(token)
    assert.ok(verify(token, pki.publicKeyToPem(keyPair.publicKey)))
  })
})
github michaellperry / jinaga / src / memory / memory-keystore.ts View on Github external
private generateKeyPair(key: string) {
        const keypair = pki.rsa.generateKeyPair({ bits: 1024 });
        const privateKey = pki.privateKeyToPem(keypair.privateKey);
        const publicKey = pki.publicKeyToPem(keypair.publicKey);
        this.keyPairs[key] = { publicKey, privateKey };
        return publicKey;
    }
}
github matianfu / telsa / src / telsa.js View on Github external
sendClientKeyExchange () {
    this.sendHandshakeMessage(HandshakeType.CLIENT_KEY_EXCHANGE,
      prepend16(publicEncrypt({
        key: pki.publicKeyToPem(this.serverCertificates[0].publicKey),
        padding: RSA_PKCS1_PADDING
      }, this.preMasterSecret)))
  }
github poetapp / poet-js / src / util / KeyHelper.ts View on Github external
export const generateRsaKeyPems = () => {
  const keyPair = generateRsaKeyPair()
  return {
    publicKey: pki.publicKeyToPem(keyPair.publicKey),
    privateKey: pki.privateKeyToPem(keyPair.privateKey),
  }
}