marcialwushu / JWK

:book: Studing and Validate
0 stars 0 forks source link

How to obtain value of "x5t" using Certificate credentials for application authentication #6

Open marcialwushu opened 2 years ago

marcialwushu commented 2 years ago
echo $(openssl x509 -in your.cert.pem -fingerprint -noout) | sed 's/SHA1 Fingerprint=//g' | sed 's/://g' | xxd -r -ps | base64
p12 = OpenSSL::PKCS12.new(File.read(CERT_FILE), '')
x509_sha1_thumbprint = Base64.encode64(OpenSSL::Digest::SHA1.new(p12.certificate.to_der).to_s.upcase.scan(/../).map(&:hex).pack("c*")).strip
jwt_token = JWT.encode payload, p12.key, 'RS256', { typ: 'JWT', x5t: x509_sha1_thumbprint }
marcialwushu commented 2 years ago

https://stackoverflow.com/questions/50657463/how-to-obtain-value-of-x5t-using-certificate-credentials-for-application-authe