summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBill Janssen <janssen@parc.com>2007-09-05 00:46:27 (GMT)
committerBill Janssen <janssen@parc.com>2007-09-05 00:46:27 (GMT)
commitffe576dc78cbdfb5f5e5625fa0a54ca1ce7b3bdc (patch)
tree4ac022f14e17811366b66a9c61c8cfa148beb905 /Modules
parent38336406ebdbe5d524f29483b3c2c3d47d1d76af (diff)
downloadcpython-ffe576dc78cbdfb5f5e5625fa0a54ca1ce7b3bdc.zip
cpython-ffe576dc78cbdfb5f5e5625fa0a54ca1ce7b3bdc.tar.gz
cpython-ffe576dc78cbdfb5f5e5625fa0a54ca1ce7b3bdc.tar.bz2
SSL certificate distinguished names should be represented by tuples
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ssl.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index a1c2380..a34c3c8 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -437,12 +437,15 @@ PySSL_issuer(PySSLObject *self)
}
static PyObject *
-_create_dict_for_X509_NAME (X509_NAME *xname)
+_create_tuple_for_X509_NAME (X509_NAME *xname)
{
- PyObject *pd = PyDict_New();
+ PyObject *pt = NULL;
+ PyObject *entry_tuple = NULL;
+ int entry_count = X509_NAME_entry_count(xname);
int index_counter;
- if (pd == NULL)
+ pt = PyTuple_New(entry_count);
+ if (pt == NULL)
return NULL;
for (index_counter = 0;
@@ -480,18 +483,20 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
Py_DECREF(name_obj);
goto fail0;
}
- if (PyDict_SetItem(pd, name_obj, value_obj) < 0) {
+ entry_tuple = PyTuple_New(2);
+ if (entry_tuple == NULL) {
Py_DECREF(name_obj);
Py_DECREF(value_obj);
goto fail0;
}
- Py_DECREF(name_obj);
- Py_DECREF(value_obj);
+ PyTuple_SET_ITEM(entry_tuple, 0, name_obj);
+ PyTuple_SET_ITEM(entry_tuple, 1, value_obj);
+ PyTuple_SET_ITEM(pt, index_counter, entry_tuple);
}
- return pd;
+ return pt;
fail0:
- Py_XDECREF(pd);
+ Py_XDECREF(pt);
return NULL;
}
@@ -520,7 +525,7 @@ PySSL_peercert(PySSLObject *self)
if ((verification & SSL_VERIFY_PEER) == 0)
return retval;
- peer = _create_dict_for_X509_NAME(
+ peer = _create_tuple_for_X509_NAME(
X509_get_subject_name(self->peer_cert));
if (peer == NULL)
goto fail0;
@@ -530,7 +535,7 @@ PySSL_peercert(PySSLObject *self)
}
Py_DECREF(peer);
- issuer = _create_dict_for_X509_NAME(
+ issuer = _create_tuple_for_X509_NAME(
X509_get_issuer_name(self->peer_cert));
if (issuer == NULL)
goto fail0;