/usr/share/doc/python-gnutls/examples/client.py is in python-gnutls 3.0.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/usr/bin/env python
"""Synchronous client using python-gnutls"""
import sys
import os
import socket
from gnutls.crypto import *
from gnutls.connection import *
script_path = os.path.realpath(os.path.dirname(sys.argv[0]))
certs_path = os.path.join(script_path, 'certs')
cert = X509Certificate(open(certs_path + '/valid.crt').read())
key = X509PrivateKey(open(certs_path + '/valid.key').read())
ca = X509Certificate(open(certs_path + '/ca.pem').read())
crl = X509CRL(open(certs_path + '/crl.pem').read())
cred = X509Credentials(cert, key)
context = TLSContext(cred)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
session = ClientSession(sock, context)
session.connect(('localhost', 10000))
session.handshake()
session.send("test\r\n")
buf = session.recv(1024)
print 'Received: ', buf.rstrip()
session.bye()
session.close()
|