def GetValidHostsForCert(cert):
 if ('subjectAltName' in cert):
  return [x[1] for x in cert['subjectAltName'] if (x[0].lower() == 'dns')]
 else:
  return [x[0][1] for x in cert['subject'] if (x[0][0].lower() == 'commonname')]

def GetValidHostsForCert ( cert ) : if ( 'subjectAltName' in cert ) : return [ x [ 1 ] for x in cert [ 'subjectAltName' ] if ( x [ 0 ] . lower ( ) == 'dns' ) ] else : return [ x [ 0 ] [ 1 ] for x in cert [ 'subject' ] if ( x [ 0 ] [ 0 ] . lower ( ) == 'commonname' ) ]
returns a list of valid host globs for an ssl certificate .