Commit c9cdfa3f authored by Christian Heimes's avatar Christian Heimes

Issue #18147: Add missing documentation for SSLContext.get_ca_certs().

Also change the argument name to the same name as getpeercert()
parent 1726c246
...@@ -1093,6 +1093,18 @@ to speed up repeated connections from the same clients. ...@@ -1093,6 +1093,18 @@ to speed up repeated connections from the same clients.
>>> stats['hits'], stats['misses'] >>> stats['hits'], stats['misses']
(0, 0) (0, 0)
.. method:: SSLContext.get_ca_certs(binary_form=False)
Returns a list of dicts with information of loaded CA certs. If the
optional argument is True, returns a DER-encoded copy of the CA
certificate.
.. note::
Certificates in a capath directory aren't loaded unless they have
been used at least once.
.. versionadded:: 3.4
.. attribute:: SSLContext.options .. attribute:: SSLContext.options
An integer representing the set of SSL options enabled on this context. An integer representing the set of SSL options enabled on this context.
......
...@@ -3023,7 +3023,7 @@ cert_store_stats(PySSLContext *self) ...@@ -3023,7 +3023,7 @@ cert_store_stats(PySSLContext *self)
} }
PyDoc_STRVAR(PySSL_get_ca_certs_doc, PyDoc_STRVAR(PySSL_get_ca_certs_doc,
"get_ca_certs([der=False]) -> list of loaded certificate\n\ "get_ca_certs(binary_form=False) -> list of loaded certificate\n\
\n\ \n\
Returns a list of dicts with information of loaded CA certs. If the\n\ Returns a list of dicts with information of loaded CA certs. If the\n\
optional argument is True, returns a DER-encoded copy of the CA certificate.\n\ optional argument is True, returns a DER-encoded copy of the CA certificate.\n\
...@@ -3031,14 +3031,16 @@ NOTE: Certificates in a capath directory aren't loaded unless they have\n\ ...@@ -3031,14 +3031,16 @@ NOTE: Certificates in a capath directory aren't loaded unless they have\n\
been used at least once."); been used at least once.");
static PyObject * static PyObject *
get_ca_certs(PySSLContext *self, PyObject *args) get_ca_certs(PySSLContext *self, PyObject *args, PyObject *kwds)
{ {
char *kwlist[] = {"binary_form", NULL};
X509_STORE *store; X509_STORE *store;
PyObject *ci = NULL, *rlist = NULL; PyObject *ci = NULL, *rlist = NULL;
int i; int i;
int binary_mode = 0; int binary_mode = 0;
if (!PyArg_ParseTuple(args, "|p:get_ca_certs", &binary_mode)) { if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p:get_ca_certs",
kwlist, &binary_mode)) {
return NULL; return NULL;
} }
...@@ -3119,7 +3121,7 @@ static struct PyMethodDef context_methods[] = { ...@@ -3119,7 +3121,7 @@ static struct PyMethodDef context_methods[] = {
{"cert_store_stats", (PyCFunction) cert_store_stats, {"cert_store_stats", (PyCFunction) cert_store_stats,
METH_NOARGS, PySSL_get_stats_doc}, METH_NOARGS, PySSL_get_stats_doc},
{"get_ca_certs", (PyCFunction) get_ca_certs, {"get_ca_certs", (PyCFunction) get_ca_certs,
METH_VARARGS, PySSL_get_ca_certs_doc}, METH_VARARGS | METH_KEYWORDS, PySSL_get_ca_certs_doc},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment