Author: Armin Rigo <[email protected]>
Branch: stdlib-2.7.13
Changeset: r89160:642126fc25ea
Date: 2016-12-18 19:43 +0100
http://bitbucket.org/pypy/pypy/changeset/642126fc25ea/
Log: ssl fix for test_parse_all_sans
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
@@ -897,10 +897,24 @@
length = libssl_ASN1_STRING_length(as_)
w_t = space.newtuple([
v, space.wrap(rffi.charpsize2str(buf, length))])
+ elif gntype == GEN_RID:
+ with lltype.scoped_alloc(rffi.CCHARP.TO, 2048) as buf:
+ d_rid = libssl_pypy_GENERAL_NAME_rid(name)
+ length = libssl_i2t_ASN1_OBJECT(buf, 2047, d_rid)
+ if length < 0:
+ raise _ssl_seterror(space, None, 0)
+ elif length >= 2048:
+ v = "<INVALID>"
+ else:
+ v = rffi.charpsize2str(buf, length)
+ w_t = space.newtuple([
+ space.wrap("Registered ID"),
+ space.call_function(space.w_unicode,
+ space.wrap(v))])
else:
# for everything else, we use the OpenSSL print form
if gntype not in (GEN_OTHERNAME, GEN_X400,
GEN_EDIPARTY,
- GEN_IPADD, GEN_RID):
+ GEN_IPADD):
space.warn(space.wrap("Unknown general name type"),
space.w_RuntimeWarning)
libssl_BIO_reset(biobuf)
@@ -911,6 +925,9 @@
raise _ssl_seterror(space, None, 0)
v = rffi.charpsize2str(buf, length)
+ if ':' not in v:
+ raise oefmt(space.w_ValueError,
+ "Invalid value %s", v)
v1, v2 = v.split(':', 1)
w_t = space.newtuple([space.wrap(v1),
space.wrap(v2)])
diff --git a/lib-python/2.7/test/allsans.pem b/pypy/module/_ssl/test/allsans.pem
copy from lib-python/2.7/test/allsans.pem
copy to pypy/module/_ssl/test/allsans.pem
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
@@ -8,6 +8,8 @@
def setup_class(cls):
cls.w_nullbytecert = cls.space.wrap(os.path.join(
os.path.dirname(__file__), 'nullbytecert.pem'))
+ cls.w_allsans = cls.space.wrap(os.path.join(
+ os.path.dirname(__file__), 'allsans.pem'))
def test_init_module(self):
import _ssl
@@ -121,6 +123,10 @@
('IP Address', '192.0.2.1'),
('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
+ def test_decode_all_sans(self):
+ import _ssl
+ _ssl._test_decode_cert(self.allsans)
+
def test_context(self):
import _ssl
s = _ssl._SSLContext(_ssl.PROTOCOL_TLS)
diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py
--- a/rpython/rlib/ropenssl.py
+++ b/rpython/rlib/ropenssl.py
@@ -55,6 +55,7 @@
# Unnamed structures are not supported by rffi_platform.
# So we replace an attribute access with a macro call.
'#define pypy_GENERAL_NAME_dirn(name) (name->d.dirn)',
+ '#define pypy_GENERAL_NAME_rid(name) (name->d.rid)',
'#define pypy_GENERAL_NAME_uri(name)
(name->d.uniformResourceIdentifier)',
'#define pypy_GENERAL_NAME_pop_free(names)
(sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free))',
'#define pypy_DIST_POINT_fullname(obj)
(obj->distpoint->name.fullname)',
@@ -436,6 +437,7 @@
save_err=SAVE_ERR)
ssl_external('ASN1_TIME_print', [BIO, ASN1_TIME], rffi.INT)
ssl_external('i2a_ASN1_INTEGER', [BIO, ASN1_INTEGER], rffi.INT)
+ssl_external('i2t_ASN1_OBJECT', [rffi.CCHARP, rffi.INT, ASN1_OBJECT], rffi.INT)
ssl_external('ASN1_item_d2i',
[rffi.VOIDP, rffi.CCHARPP, rffi.LONG, ASN1_ITEM], rffi.VOIDP)
ssl_external('ASN1_ITEM_ptr', [ASN1_ITEM_EXP], ASN1_ITEM, macro=True)
@@ -475,6 +477,8 @@
ssl_external('GENERAL_NAME_print', [BIO, GENERAL_NAME], rffi.INT)
ssl_external('pypy_GENERAL_NAME_dirn', [GENERAL_NAME], X509_NAME,
macro=True)
+ssl_external('pypy_GENERAL_NAME_rid', [GENERAL_NAME], ASN1_OBJECT,
+ macro=True)
ssl_external('pypy_GENERAL_NAME_uri', [GENERAL_NAME], ASN1_IA5STRING,
macro=True)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit