[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-svn
Subject:    [pypy-commit] pypy stdlib-2.7.9: Fix ssl.context setter
From:       amauryfa <noreply () buildbot ! pypy ! org>
Date:       2015-01-30 23:45:12
Message-ID: 20150130234512.13F9E1C0FAB () cobra ! cs ! uni-duesseldorf ! de
[Download RAW message or body]

Author: Amaury Forgeot d'Arc <amauryfa@gmail.com>
Branch: stdlib-2.7.9
Changeset: r75592:1e72ec33c3c4
Date: 2015-01-26 22:45 +0100
http://bitbucket.org/pypy/pypy/changeset/1e72ec33c3c4/

Log:	Fix ssl.context setter

diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -9,7 +9,7 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
 from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.typedef import TypeDef, GetSetProperty, interp_attrproperty_w
+from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.module._ssl.ssl_data import (
     LIBRARY_CODES_TO_NAMES, ERROR_CODES_TO_NAMES)
 from pypy.module._socket import interp_socket
@@ -591,6 +591,18 @@
             if length > 0:
                 return space.wrap(rffi.charpsize2str(buf, intmask(length)))
 
+    def descr_get_context(self, space):
+        return self.w_ctx
+
+    def descr_set_context(self, space, w_ctx):
+        ctx = space.interp_w(_SSLContext, w_ctx)
+        if not HAS_SNI:
+            raise oefmt(space.w_NotImplementedError,
+                        "setting a socket's context "
+                        "is not supported by your OpenSSL library")
+        self.w_ctx = w_ctx
+        libssl_SSL_set_SSL_CTX(self.ssl, ctx.ctx)
+
 
 _SSLSocket.typedef = TypeDef(
     "_ssl._SSLSocket",
@@ -606,7 +618,8 @@
     compression = interp2app(_SSLSocket.compression_w),
     version = interp2app(_SSLSocket.version_w),
     tls_unique_cb = interp2app(_SSLSocket.tls_unique_cb_w),
-    context=interp_attrproperty_w("w_ctx", _SSLSocket),
+    context=GetSetProperty(_SSLSocket.descr_get_context,
+                           _SSLSocket.descr_set_context),
 )
 
 
diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py
--- a/rpython/rlib/ropenssl.py
+++ b/rpython/rlib/ropenssl.py
@@ -240,6 +240,7 @@
     ssl_external('RAND_egd', [rffi.CCHARP], rffi.INT)
 ssl_external('SSL_CTX_new', [SSL_METHOD], SSL_CTX)
 ssl_external('SSL_get_SSL_CTX', [SSL], SSL_CTX)
+ssl_external('SSL_set_SSL_CTX', [SSL, SSL_CTX], SSL_CTX)
 ssl_external('TLSv1_method', [], SSL_METHOD)
 ssl_external('SSLv2_method', [], SSL_METHOD)
 ssl_external('SSLv3_method', [], SSL_METHOD)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic