0

I have a certificate and i used the regular expression to strip the beginning and ending from certificate. How can i decode the serial number of the certificate using OpenSSL.

I have the cli command to decode:

openssl x509 -serial -noout

how can fetch it from Python

Ebin Davis
  • 5,421
  • 3
  • 15
  • 20
  • What have you tried or researched already? – Klaus D. Jul 25 '18 at 06:22
  • @KlausD. i tried ' openssl x509 -in CERTIFICATE_FILE -serial -noout' where variable CERTIFICATE_FILE is having the certificate ( after stripped using regex). Failed. – Ebin Davis Jul 25 '18 at 06:31
  • Show us your Python code! – Klaus D. Jul 25 '18 at 07:10
  • `m = re.search(r"(?<=-----BEGIN CERTIFICATE-----).*?(?=-----END CERTIFICATE-----)", s, flags=re.DOTALL) if m: print( m.group() ) CERTIFICATE_FILE= m.group() res= subprocess.getstatusoutput('openssl x509 -in CERTIFICATE_FILE -serial -noout' ) print(res)` @KlausD. – Ebin Davis Jul 25 '18 at 07:17

0 Answers0