Skip to content

Instantly share code, notes, and snippets.

View Fengson's full-sized avatar
🏠
Working from home

Szymon Kadluczka Fengson

🏠
Working from home
View GitHub Profile
@Fengson
Fengson / publickey
Created January 24, 2022 08:58 — forked from WeRockStar/publickey
Extract the public key from a certificate
Generate public key + sha256 rely on X.509
1. openssl s_client -connect api.github.com:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
2. openssl x509 -noout -in certificate.pem -pubkey | openssl asn1parse -noout -inform pem -out public.key openssl dgst -sha256 -binary public.key | openssl enc -base64
3. openssl rsa -in my-rsa-key-file.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64
4. openssl req -in my-signing-request.csr -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
5. openssl x509 -in my-certificate.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
Covert PEM to DER
openssl x509 -outform der -in certificate.pem -out certificate.der