#!/usr/bin/python

from gi.repository import Gio

for NAME in ["www.libreoffice.org", "gentoo.org"]:
    print "Testing: ", NAME
    host = Gio.NetworkAddress.new(NAME, 443)
    socket = Gio.SocketClient()
    connection = socket.connect(host, None)
    tls_connection = Gio.TlsClientConnection.new(connection, host)
    print "using db:", tls_connection.get_database().get_property("anchors")
    try:
        tls_connection.handshake(None)
        print "OK"
    except Exception as e:
        print "Error in handshake: ", e
        print "error details", tls_connection.get_peer_certificate_errors()
