diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2014-03-10 17:29:27 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2014-03-10 17:29:27 +1300 |
commit | f5cc63d653b27210d9c3d7646c01c3a9d540d9c7 (patch) | |
tree | c52924dd1e31bd465751491166a4774d1e9ea49d /netlib/certffi.py | |
parent | 2a12aa3c47d57cc2d3a36f6726a5f081ca493457 (diff) | |
download | mitmproxy-f5cc63d653b27210d9c3d7646c01c3a9d540d9c7.tar.gz mitmproxy-f5cc63d653b27210d9c3d7646c01c3a9d540d9c7.tar.bz2 mitmproxy-f5cc63d653b27210d9c3d7646c01c3a9d540d9c7.zip |
Certificate flags
Diffstat (limited to 'netlib/certffi.py')
-rw-r--r-- | netlib/certffi.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/netlib/certffi.py b/netlib/certffi.py new file mode 100644 index 00000000..c5d7c95e --- /dev/null +++ b/netlib/certffi.py @@ -0,0 +1,36 @@ +import cffi +import OpenSSL +xffi = cffi.FFI() +xffi.cdef (""" + struct rsa_meth_st { + int flags; + ...; + }; + struct rsa_st { + int pad; + long version; + struct rsa_meth_st *meth; + ...; + }; +""") +xffi.verify( + """#include <openssl/rsa.h>""", + extra_compile_args=['-w'] +) + +def handle(privkey): + new = xffi.new("struct rsa_st*") + newbuf = xffi.buffer(new) + rsa = OpenSSL.SSL._lib.EVP_PKEY_get1_RSA(privkey._pkey) + oldbuf = OpenSSL.SSL._ffi.buffer(rsa) + newbuf[:] = oldbuf[:] + return new + +def set_flags(privkey, val): + hdl = handle(privkey) + hdl.meth.flags = val + return privkey + +def get_flags(privkey): + hdl = handle(privkey) + return hdl.meth.flags |