From 7ebbbaaeef0ded0f39b8bf863ee7fd324b19c9f9 Mon Sep 17 00:00:00 2001 From: k clair Date: Tue, 9 Oct 2012 12:13:13 -0700 Subject: Add source files for python-gnutls version 1.1.9 --- python-gnutls-1.1.9/examples/client.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 python-gnutls-1.1.9/examples/client.py (limited to 'python-gnutls-1.1.9/examples/client.py') diff --git a/python-gnutls-1.1.9/examples/client.py b/python-gnutls-1.1.9/examples/client.py new file mode 100755 index 0000000..c6e4208 --- /dev/null +++ b/python-gnutls-1.1.9/examples/client.py @@ -0,0 +1,32 @@ +#!/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) + +sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +session = ClientSession(sock, cred) + +session.connect(('localhost', 10000)) +session.handshake() +session.send("test\r\n") +buf = session.recv(1024) +print 'Received: ', buf.rstrip() +session.bye() +session.shutdown() +session.close() + -- cgit v1.2.3