-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathssl-forward-cert.py
More file actions
46 lines (32 loc) · 934 Bytes
/
ssl-forward-cert.py
File metadata and controls
46 lines (32 loc) · 934 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python2
import sys
sys.path.insert(0, '.')
from ssl import CERT_OPTIONAL
from circuits import Debugger
from circuits.http.server.resource import method
from circuits.net.sockets import TCPServer
from resource import BaseResource as Resource
from server import HTTPServer
class SSLSocket(TCPServer):
def __init__(self, channel):
super(SSLSocket, self).__init__(
('', 8443),
secure=True,
certfile="./ssl/server-cert.pem",
keyfile="./ssl/server-key.pem",
ca_certs="./ssl/ca-chain.pem",
cert_reqs=CERT_OPTIONAL,
channel=channel,
)
class PeerCert(Resource):
channel = '/'
@method
def GET(self, client):
return "You are providing the following cert: %s" % (client.ssl.cert,)
GET.codec('application/json')
if __name__ == '__main__':
server = HTTPServer()
server += SSLSocket(channel=server.channel)
server.localhost += PeerCert()
server += Debugger(events=True)
server.run()