summaryrefslogtreecommitdiff
path: root/leakcheck/context-verify-callback.py
diff options
context:
space:
mode:
Diffstat (limited to 'leakcheck/context-verify-callback.py')
-rw-r--r--leakcheck/context-verify-callback.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/leakcheck/context-verify-callback.py b/leakcheck/context-verify-callback.py
index 0ae586b..b9ce1d5 100644
--- a/leakcheck/context-verify-callback.py
+++ b/leakcheck/context-verify-callback.py
@@ -11,7 +11,13 @@ from itertools import count
from threading import Thread
from socket import socket
-from OpenSSL.SSL import Context, TLSv1_METHOD, VERIFY_PEER, Connection, WantReadError
+from OpenSSL.SSL import (
+ Context,
+ TLSv1_METHOD,
+ VERIFY_PEER,
+ Connection,
+ WantReadError,
+)
from OpenSSL.crypto import FILETYPE_PEM, load_certificate, load_privatekey
cleartextPrivateKeyPEM = (
@@ -29,7 +35,8 @@ cleartextPrivateKeyPEM = (
"0QwrX8nxFeTytr8pFGezj4a4KVCdb2B3CL+p3f70K7RIo9d/7b6frJI6ZL/LHQf2\n"
"UP4pKRDkgKsVDx7MELECQGm072/Z7vmb03h/uE95IYJOgY4nfmYs0QKA9Is18wUz\n"
"DpjfE33p0Ha6GO1VZRIQoqE24F8o5oimy3BEjryFuw4=\n"
- "-----END RSA PRIVATE KEY-----\n")
+ "-----END RSA PRIVATE KEY-----\n"
+)
cleartextCertificatePEM = (
@@ -48,25 +55,32 @@ cleartextCertificatePEM = (
"q55LJdOnJbCCXIgxLdoVmvYAz1ZJq1eGKgKWI5QLgxiSzJLEU7KK//aVfiZzoCd5\n"
"RipBiEEMEV4eAY317bHPwPP+4Bj9t0l8AsDLseC5vLRHgxrLEu3bn08DYx6imB5Q\n"
"UBj849/xpszEM7BhwKE0GiQ=\n"
- "-----END CERTIFICATE-----\n")
+ "-----END CERTIFICATE-----\n"
+)
count = count()
+
+
def go():
port = socket()
- port.bind(('', 0))
+ port.bind(("", 0))
port.listen(1)
called = []
+
def info(*args):
print count.next()
called.append(None)
return 1
+
context = Context(TLSv1_METHOD)
context.set_verify(VERIFY_PEER, info)
context.use_certificate(
- load_certificate(FILETYPE_PEM, cleartextCertificatePEM))
+ load_certificate(FILETYPE_PEM, cleartextCertificatePEM)
+ )
context.use_privatekey(
- load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM))
+ load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM)
+ )
while 1:
client = socket()
@@ -86,7 +100,7 @@ def go():
while not called:
for ssl in clientSSL, serverSSL:
try:
- ssl.send('foo')
+ ssl.send("foo")
except WantReadError, e:
pass
@@ -96,4 +110,3 @@ for th in threads:
th.start()
for th in threads:
th.join()
-