def cert_get_cn(cert):
 return cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME)[0].value.strip()

def cert_get_cn ( cert ) : return cert . subject . get_attributes_for_oid ( x509 . OID_COMMON_NAME ) [ 0 ] . value . strip ( )
attempts to get a sane common name from a given certificate .