Assume we have certificate_1.pem signed by issuer with its private key issuer_private_key.pem
When certificate_1.pem was created, pieces of information are filled into the request as the certificate to be signed.
Then the issuer:
- verify the information in the request
- generate a hash of the tbsCertificate
- encrypt the using issuer's private key as the signature
- this signature is embedded into the signed certificate_1.pem
So the verification simply goes in following steps:
- compute the hash of the tbsCertificate as hash_calculated
- pull the signature from the certificate
openssl x509 -in certificate.pem -noout -text
- convert signature from 'FE:ED:..:10' to 0xfeed...10 as integer S
- pull the public key from the issuer's private key
openssl rsa -in issuer_private_key.pem -pubout -out issuer_public_key.pem
- get the modulus and exponent(usually 65537) from the pubkey.
openssl rsa -in issuer_public_key.pem -pubin -noout -text
- convert the modulus into integer M in the form of 0xffff...ff
- decrypt the signature using the issuer's public key as hash_expected
- get the last 40/64 characters from
pow(S, 65537, M)
according to your hash algorithms. - compare hash_calculated with hash_expected