Skip to content

Commit 547ab5f

Browse files
committed
open the cert store readonly
Patch from Chi Hsuan Yen.
1 parent 0224638 commit 547ab5f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Core and Builtins
1616
Library
1717
-------
1818

19+
- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates.
20+
1921
- Issue #22570: Add 'path' attribute to pathlib.Path objects,
2022
returning the same as str(), to make it more similar to DirEntry.
2123
Library code can now write getattr(p, 'path', p) to get the path as

Modules/_ssl.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,7 +3597,9 @@ PySSL_enum_certificates(PyObject *self, PyObject *args, PyObject *kwds)
35973597
if (result == NULL) {
35983598
return NULL;
35993599
}
3600-
hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name);
3600+
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL,
3601+
CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE,
3602+
store_name);
36013603
if (hStore == NULL) {
36023604
Py_DECREF(result);
36033605
return PyErr_SetFromWindowsErr(GetLastError());
@@ -3685,7 +3687,9 @@ PySSL_enum_crls(PyObject *self, PyObject *args, PyObject *kwds)
36853687
if (result == NULL) {
36863688
return NULL;
36873689
}
3688-
hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name);
3690+
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL,
3691+
CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE,
3692+
store_name);
36893693
if (hStore == NULL) {
36903694
Py_DECREF(result);
36913695
return PyErr_SetFromWindowsErr(GetLastError());

0 commit comments

Comments
 (0)