remote pool_handle_t
[tlspool] / tool / webclientdemo.py
1 #!/usr/bin/env python
2 #
3 # webclientdemo.py -- Access the website configured below, and retrieve path /
4 #
5 # From: Rick van Rein <rick@openfortress.nl>
6
7 import sys
8 import socket
9
10 # Demo path
11 sys.path.append ('../lib')
12 import tlspool
13
14 # Configuration
15 #
16 webhost = 'research.arpa2.org'
17 #
18 tlsdata = {
19         'localid': 'testcli@tlspool.arpa2.lab',
20         'remoteid': 'testsrv@tlspool.arpa2.lab',
21 }
22 #
23 # End of Configuration
24
25 privdata = { }
26
27 sox = socket.socket (socket.AF_INET6, socket.SOCK_STREAM, 0)
28 sox.connect ( ('::1', 22335) )
29
30 retval = tlspool.starttls_client (sox, tlsdata, privdata)
31
32 print 'RETVAL =', retval
33 print 'PRIVDATA =', privdata
34 print 'TLSDATA =', tlsdata
35
36 if retval == 0:
37         plainfd = privdata ['plainfd']
38         plainfd.send ('GET / HTTP/1.0\r\nHost: ' + webhost + '\r\n\r\n')
39         print 'OUTPUT:'
40         txt = plainfd.recv (1024)
41         while txt != '':
42                 print txt,
43                 txt = plainfd.recv (1024)
44