You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My understanding is that with the x5c (and jwk) header parameters there's no need to specify a key when verifying. That would be a verify/1 function in JWS module.
If somebody else finds this issue when trying to validate App Store Server Notifications v2, this is how this can be done:
# Extract certificates from the x5c field in the header%{"x5c"=>x5c}=jws|>JOSE.JWS.peek_protected()|>Jason.decode!()# Base64 decode and reverse them to the format expected by the verify functioncert_chain=Enum.map(x5c,&Base.decode64!/1)|>Enum.reverse()# Verify certificate chain and extract the public key%Req.Response{body: trusted_cert}=Req.get!("https://www.apple.com/certificateauthority/AppleRootCA-G3.cer"){:ok,{{_key_oid_name,public_key_type,public_key_params},_policy_tree}}=:public_key.pkix_path_validation(trusted_cert,cert_chain,[])public_key={public_key_type,public_key_params}# Convert the public key into a JSON Web Keyjwk=JOSE.JWK.from_key(public_key)# Verify the signature of the JWS{true,payload,_jose_jws_protected_details}=JOSE.JWS.verify(jwk,jws)
My understanding is that with the x5c (and jwk) header parameters there's no need to specify a key when verifying. That would be a verify/1 function in JWS module.
Specification: https://tools.ietf.org/html/rfc7515#section-4.1.6
I've seen it in the wild, for example FIDO2 metadata are published in such JWTs (https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-metadata-service-v2.0-id-20180227.html#metadata-toc-object-processing-rules).
The text was updated successfully, but these errors were encountered: