Find if a certificate is self signed or CA signed

前端 未结 5 1724
情歌与酒
情歌与酒 2021-02-02 11:59

I have a web app, which allows user to upload pkcs12. I store the pkcs12 as binary in database. Is there any way for me to know if the certificate in the pkcs12 is self signed

5条回答
  •  你的背包
    2021-02-02 12:18

    Following email thread precisely tells the right way to verify if the base64 encoded certificate (i.e. PEM) is self signed or not: http://marc.info/?l=openssl-users&m=116177485311662&w=4

    Following is the code snippet:

    openssl verify -CAfile self_signed_cert.pem self_signed_cert.pem
    

    should return:

    self_signed_cert.pem: OK
    

    OR compare the issuer and subject. If they are same, it is self signed

    openssl x509 -in cert.pem -inform PEM -noout -subject -issuer
    

提交回复
热议问题