'Manually parse the certificate line by line'

def _parse_cert(self):

    self.extensions = []
    PARSING_ALT_NAMES = False
    PARSING_HEX_SERIAL = False
    for line in self.cert_string.split('\n'):
        l = line.strip()
        if PARSING_ALT_NAMES:
            self.extensions.append(FakeOpenSSLCertificateSANExtension(l))
            PARSING_ALT_NAMES = False
            continue
        if PARSING_HEX_SERIAL:
            serial_raw = l.replace(':', '')
            self.serial = int(('0x' + serial_raw), base=16)
            PARSING_HEX_SERIAL = False
            continue
        if l.startswith('Serial    Number:'):
            if l.endswith(':'):
                PARSING_HEX_SERIAL = True
                continue
            self.serial = int(l.split()[(-2)])
        elif l.startswith('Not    After    :'):
            not_after_raw = l.partition('    :    ')[(-1)]
            not_after_parsed = datetime.datetime.strptime(not_after_raw, '%b    %d    %H:%M:%S    %Y    %Z')
            self.not_after = not_after_parsed.strftime('%Y%m%d%H%M%SZ')
        elif l.startswith('X509v3    Subject    Alternative    Name:'):
            PARSING_ALT_NAMES = True
            continue
        elif l.startswith('Subject:'):
            self.subject = FakeOpenSSLCertificateSubjects(l.partition(':    ')[(-1)])
