Skip to content

Convert a certificate public key to JWK

Extract the public key from a PEM certificate, convert it to JSON Web Key form, and format the result.

Install in Serialize

What it can do

  • Read a PEM certificate
  • Separate its public key
  • Convert RSA key material to JWK
  • Format the JSON deterministically

How the recipe works

Public Key from Certificate

Extract the SubjectPublicKeyInfo block from the certificate.

PEM to JWK

Convert the PEM public key to JWK fields.

JSON Beautify

Indent and sort the JSON object.

Demonstration

Sample input

-----BEGIN CERTIFICATE-----
MIIB4TCCAYugAwIBAgIUbI1I37oK514UVheqDDJIZpsCH7UwDQYJKoZIhvcNAQEL
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMjEwMjgxMDA3NDlaFw0yMzEw
MjgxMDA3NDlaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwXDANBgkqhkiG9w0BAQEF
AANLADBIAkEAnBvviHCQdvphT22rK0ARKEk2xdM/1jJnzVZmnYkxmvHkYf6TXmmg
wPknPzWBmfYi3OxO+nU5WndNqmCZUMLQawIDAQABo1MwUTAdBgNVHQ4EFgQUl61B
Vqhuq6C33YUxBufsKbM58a8wHwYDVR0jBBgwFoAUl61BVqhuq6C33YUxBufsKbM5
8a8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAANBAAXBdiCffhXvpkJ6
zsUe9rLJPmpBhmNORqsv9yGvfzjCWsW4U9vLtlSmqwuEsNuoSH9z30bdNw4O4nJ9
Hm5CO40=
-----END CERTIFICATE-----

Expected result

An RSA JWK containing kty, n, and e fields.

When to use it

  • OIDC and JWT integration debugging
  • Certificate-to-JWK migration
  • Comparing published key material

Adapt it

Add a JWK thumbprint operation or compare the modulus with a JWKS entry when validating key publication.

Source and verification

Adapted from GCHQ CyberChef project and examples. The explanation and sample are written for Serialize, use synthetic or documentation-safe data, and are checked against the current operation catalogue. The workflow runs locally without an external API call.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close