Skip to content

Instantly share code, notes, and snippets.

@chatu
Created September 10, 2018 18:50
Show Gist options
  • Save chatu/7738411c7e8dcf604bc5a0aad7937299 to your computer and use it in GitHub Desktop.
Save chatu/7738411c7e8dcf604bc5a0aad7937299 to your computer and use it in GitHub Desktop.
Convert JWKS cert to PEM
/**
* If you wanted to use `n` and `e` from JWKS check out node-jwks-rsa's implementation:
* https://github.com/auth0/node-jwks-rsa/blob/master/src/utils.js#L35-L57
*/
export function certToPEM(cert) {
cert = cert.match(/.{1,64}/g).join('\n');
cert = `-----BEGIN CERTIFICATE-----\n${cert}\n-----END CERTIFICATE-----\n`;
return cert;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment