From: Benjamin Peterson Date: Thu, 18 Feb 2016 06:13:19 +0000 (-0800) Subject: open the cert store readonly X-Git-Tag: v3.4.5rc1~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94912727513ccab03567cfcab01732989c0ababc;p=thirdparty%2FPython%2Fcpython.git open the cert store readonly Patch from Chi Hsuan Yen. --- diff --git a/Misc/NEWS b/Misc/NEWS index 5f1929d0b1d5..f9ccc0458a66 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -16,6 +16,8 @@ Core and Builtins Library ------- +- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. + - Issue #22570: Add 'path' attribute to pathlib.Path objects, returning the same as str(), to make it more similar to DirEntry. Library code can now write getattr(p, 'path', p) to get the path as diff --git a/Modules/_ssl.c b/Modules/_ssl.c index d918671fc824..02971a75153c 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3597,7 +3597,9 @@ PySSL_enum_certificates(PyObject *self, PyObject *args, PyObject *kwds) if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); @@ -3685,7 +3687,9 @@ PySSL_enum_crls(PyObject *self, PyObject *args, PyObject *kwds) if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError());