Skip to content

Commit e1645c5

Browse files
committed
Update documentation
1 parent 8af6dbe commit e1645c5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,24 @@ rescue JWT::DecodeError
647647
end
648648
```
649649

650+
### X.509 certificate thumbprint in x5t header
651+
652+
A JWT signature can be verified using a certificate thumbprint given in the `x5t` or `x5t#S256` header.
653+
The thumbprint is a base64url-encoded SHA-1 (or SHA256) hash of the DER encoding of an X.509 certificate.
654+
The verification process involves matching this thumbprint against a set of trusted certificates.
655+
656+
```ruby
657+
# Load your trusted certificates
658+
certificates = [OpenSSL::X509::Certificate.new(File.read('cert.pem'))]
659+
660+
# Decode a JWT with x5t verification
661+
begin
662+
JWT.decode(token, nil, true, { x5t: { certificates: certificates } })
663+
rescue JWT::DecodeError
664+
# Handle error, e.g. no certificate matches the x5t thumbprint
665+
end
666+
```
667+
650668
## JSON Web Key (JWK)
651669

652670
JWK is a JSON structure representing a cryptographic key. This gem currently supports RSA, EC, OKP and HMAC keys. OKP support requires [RbNaCl](https://github.com/RubyCrypto/rbnacl) and currently only supports the Ed25519 curve.

0 commit comments

Comments
 (0)