JWK vs. PEM: what is the difference?

Question: JWK vs. PEM, what is the difference?

First, let’s define them.

JSON Web Key (JWK)

This format is defined by the JSON Web Key IETF RFC. The JSON Web Keys Set (JWKS) for your tenant is available via the https://YOUR_DOMAIN/.well-known/jwks.json endpoint. This is a standard set for the OAuth2 framework, and is typically used by applications that need to retrieve public key programmatically. This is done behind-the-scenes by most of our SDKs.

If you try the JWKS URL (with your domain) in your browser, you should see a JSON object containing keys and associated information like; which algorithm, what the key is used for, a certificate, and key ID.

If you want to learn more about JWKS, you should take a look at our JWT Handbook.

Privacy Enhanced Mail (PEM) Certificate

A PEM certificate from Auth0 is a text file containing a Base 64 encoded public key certificate. This is a common format for public and private keys, and in the context of Auth0, public signing keys are made available via the https://YOUR_DOMAIN/pem endpoint. This is a convenient way for a human to retrieve a public key for use with the JWT.io token debugger.

Take a look at some examples.

Here is an example JWKS:

{
  "keys": [
    {
      "alg": "RS256",
      "kty": "RSA",
      "use": "sig",
      "n": "sGQGrUGqZGMmDwMg1yH0jlP_186h55t95KQAeH2QVXMuLYzCnphTMWtPC5BOCFJWiiuzsvpfTmM2WmzOHDSfq8G-fmr_ZFEJJsJgxvs2B4J_MEa8h56fiCAumanHDc5Dk0MZUYUmbLghC11plC9rmotttLY0zyXdFrUdOycC9feTmB0Y7dWphlikPdLGhogWnXOKbQrEmaWe3gdlOTAhWFdB46L9KAHv9blr9OEg_ydQIAHMtX4E5yKngfGNFVQscVsBhk-KvvNbKh4nxelMfkJv1kOb3i_ablSQrC7FgxG20ULnYppQYhy2DIChQXrdjxnugJNRcy4ncnNtPs5ddw",
      "e": "AQAB",
      "kid": "8oaG5fcZCdtbKXUD2o0Q5",
      "x5t": "wtP4GQmf6Okdbz23AB-AVHxTO9g",
      "x5c": [
        "MIIDBTCCAe2gAwIBAgIJPqxTH9OmlUdcMA0GCSqGSIb3DQEBCwUAMCAxHjAcBgNVBAMTFWp3ay1kZW1vLnVzLmF1dGgwLmNvbTAeFw0yMTA0MjgyMDMwMDlaF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DQEBCwUAA4IBAQBtKk0bwVlQ
dRnHiFd4/k2MFjvdeOwjaUM9fg1QFXMsc0z1YxU21Rl4DS8855yCkWAWWCzyHi2Z
P+ooWSTE+Dtdun+uknnOMKBQWdPUJgP2S8C1iLLMrEcDdfKgOGDGgMN1f07O8HhS
gBxxtnxD5U6QbWpYEJgS7NDZ7ktzeOI3SMVXF7zR63cLsXXuMZYAX71o7itqNJ5I
urPRruSoZpcYcuxZPOmrB6CinUFHFn2J7d8AFxFu7tx3pbmzJtbvGSza086uMfxm
TRSOBFUinD8ShsgUoZsZH+i+c8TmHv5imaWTaToE7JMatmNP+9i8vhAvIM/kwpR7
R/50pkrDWCew
-----END CERTIFICATE-----

You’ll notice the x5c claim in the first key in the JWKS matches the body of the PEM certificate!

Answer:

The JWK contains the certificate in addition to other claims about the key. This information is useful for applications and servers. The PEM provides the certificate in a way that is easily human accessable for use with tools like JWT.io.

Sources:

Documentation: RFC7517, JSON Web Key Sets
Community Topics: Where is the Auth0 public key to be used in jwt.io to verify the signature of a RS256 token?

1 Like