1#!/usr/bin/env python 2# 3# This file is part of pyasn1-modules software. 4# 5# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> 6# License: http://snmplabs.com/pyasn1/license.html 7# 8# Read ASN.1/PEM OCSP response on stdin, parse into 9# plain text, then build substrate from it 10# 11import sys 12 13from pyasn1.codec.der import decoder 14from pyasn1.codec.der import encoder 15 16from pyasn1_modules import pem 17from pyasn1_modules import rfc2560 18 19if len(sys.argv) != 1: 20 print("""Usage: 21$ cat ocsp-response.pem | %s""" % sys.argv[0]) 22 sys.exit(-1) 23 24ocspReq = rfc2560.OCSPResponse() 25 26substrate = pem.readBase64FromFile(sys.stdin) 27if not substrate: 28 sys.exit(0) 29 30cr, rest = decoder.decode(substrate, asn1Spec=ocspReq) 31 32print(cr.prettyPrint()) 33 34assert encoder.encode(cr) == substrate, 'OCSP request recode fails' 35