How to read keyusage certificate of X509 V3?

I want to read the key usage field in the certificate. Is there an API in openssl?

+4
openssl x509 digital-certificate
source share
3 answers

You can try using the following command in openssl.

openssl x509 -in <certificate to check> -purpose -noout -text 

This will print a list of certificate objectives and the certificate itself.

+9
source share

Previous solutions that you need to find inside the result file / output of the "Key Usage" line. I got the following solution, which brings exactly the string to the X509 certificate to use the key.

 openssl s_client -showcerts -connect SERVER_HERE:443 </dev/null 2>/dev/null|openssl x509 -text |grep v "$(grep -E -A1 "Key Usage")" 

The above command receives a certificate, parses the text and finds the "Key Usage" line and presents the next result line, which represents the value for this particular field on the X509.

// Greetings

0
source share

Here you can get key usage of SSL certificate in python using pyOpenssl

Get key Usage using pyOpenssl

-one
source share

All Articles