summaryrefslogtreecommitdiff
path: root/leakcheck/context-passphrase-callback.py
diff options
context:
space:
mode:
Diffstat (limited to 'leakcheck/context-passphrase-callback.py')
-rw-r--r--leakcheck/context-passphrase-callback.py40
1 files changed, 0 insertions, 40 deletions
diff --git a/leakcheck/context-passphrase-callback.py b/leakcheck/context-passphrase-callback.py
deleted file mode 100644
index 141ac8d..0000000
--- a/leakcheck/context-passphrase-callback.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) Jean-Paul Calderone
-# See LICENSE for details.
-#
-# Stress tester for thread-related bugs in global_passphrase_callback in
-# src/ssl/context.c. In 0.7 and earlier, this will somewhat reliably
-# segfault or abort after a few dozen to a few thousand iterations on an SMP
-# machine (generally not on a UP machine) due to uses of Python/C API
-# without holding the GIL.
-
-from itertools import count
-from threading import Thread
-
-from OpenSSL.SSL import Context, TLSv1_METHOD
-from OpenSSL.crypto import TYPE_RSA, FILETYPE_PEM, PKey, dump_privatekey
-
-k = PKey()
-k.generate_key(TYPE_RSA, 128)
-file("pkey.pem", "w").write(
- dump_privatekey(FILETYPE_PEM, k, "blowfish", "foobar")
-)
-
-count = count()
-
-
-def go():
- def cb(a, b, c):
- print count.next()
- return "foobar"
-
- c = Context(TLSv1_METHOD)
- c.set_passwd_cb(cb)
- while 1:
- c.use_privatekey_file("pkey.pem")
-
-
-threads = [Thread(target=go, args=()) for i in xrange(2)]
-for th in threads:
- th.start()
-for th in threads:
- th.join()