Author: Karl Ramm <[email protected]>
Branch: py3k
Changeset: r62428:5ad6caf22d37
Date: 2013-03-18 18:02 -0400
http://bitbucket.org/pypy/pypy/changeset/5ad6caf22d37/

Log:    Accepting that CTX_get_options was signed was causing headaches

        The flags in the python interpreter(s) are treated as positive
        numbers, but if the high bit is set it comes back out of openssl as
        negative. This is pedantically incorrect but produces sanity-
        enhancing results.

        (CTX_set_options is also altered similarly for consiswtency as it's
        the same underlying function behind the macro)

diff --git a/pypy/module/_ssl/test/test_ssl.py 
b/pypy/module/_ssl/test/test_ssl.py
--- a/pypy/module/_ssl/test/test_ssl.py
+++ b/pypy/module/_ssl/test/test_ssl.py
@@ -212,6 +212,12 @@
         raises(ValueError, _ssl._SSLContext, -1)
         raises(ValueError, _ssl._SSLContext, 42)
 
+    def test_options(self):
+        import _ssl
+        ctx = _ssl._SSLContext(_ssl.PROTOCOL_TLSv1)
+        assert _ssl.OP_ALL == ctx.options
+
+
 
 SSL_CERTIFICATE = """
 -----BEGIN CERTIFICATE-----
diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py
--- a/rpython/rlib/ropenssl.py
+++ b/rpython/rlib/ropenssl.py
@@ -219,8 +219,8 @@
 ssl_external('SSLv23_method', [], SSL_METHOD)
 ssl_external('SSL_CTX_use_PrivateKey_file', [SSL_CTX, rffi.CCHARP, rffi.INT], 
rffi.INT)
 ssl_external('SSL_CTX_use_certificate_chain_file', [SSL_CTX, rffi.CCHARP], 
rffi.INT)
-ssl_external('SSL_CTX_get_options', [SSL_CTX], rffi.INT, macro=True)
-ssl_external('SSL_CTX_set_options', [SSL_CTX, rffi.INT], rffi.INT, macro=True)
+ssl_external('SSL_CTX_get_options', [SSL_CTX], rffi.UINT, macro=True)
+ssl_external('SSL_CTX_set_options', [SSL_CTX, rffi.INT], rffi.UINT, macro=True)
 if HAVE_SSL_CTX_CLEAR_OPTIONS:
     ssl_external('SSL_CTX_clear_options', [SSL_CTX, rffi.INT], rffi.INT,
                  macro=True)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to