parameters: (hostname)
return_statement: return ""
docstring: Uses openssl to fetch the PEM-encoded certificates for an SSL server.
docstring_summary: Uses openssl to fetch the PEM-encoded certificates for an SSL server.
docstring_tokens: Uses openssl to fetch the PEM - encoded certificates for an SSL server .
function: def read_certificates_data_from_server(hostname):
    """Uses openssl to fetch the PEM-encoded certificates for an SSL server."""
    p = subprocess.Popen(["openssl", "s_client", "-showcerts",
                          "-servername", hostname,
                          "-connect", hostname + ":443"],
                          stdin=subprocess.PIPE,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
    result = p.communicate()
  
    if p.returncode == 0:
      return result[0]
  
    sys.stderr.write("Failed getting certificates for %s:\n%s\n" % (
        hostname, result[1]))
    return ""
function_tokens: def read_certificates_data_from_server ( hostname ) : p = subprocess . Popen ( [ "openssl" , "s_client" , "-showcerts" , "-servername" , hostname , "-connect" , hostname + ":443" ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) result = p . communicate ( ) if p . returncode == 0 : return result [ 0 ] sys . stderr . write ( "Failed getting certificates for %s:\n%s\n" % ( hostname , result [ 1 ] ) ) return ""