Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Side by Side Diff: Modules/_ssl.c

Issue 25939: _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level
Patch Set: Created 4 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* SSL socket module 1 /* SSL socket module
2 2
3 SSL support based on patches by Brian E Gallew and Laszlo Kovacs. 3 SSL support based on patches by Brian E Gallew and Laszlo Kovacs.
4 Re-worked a bit by Bill Janssen to add server-side support and 4 Re-worked a bit by Bill Janssen to add server-side support and
5 certificate decoding. Chris Stawarz contributed some non-blocking 5 certificate decoding. Chris Stawarz contributed some non-blocking
6 patches. 6 patches.
7 7
8 This module is imported by ssl.py. It should *not* be used 8 This module is imported by ssl.py. It should *not* be used
9 directly. 9 directly.
10 10
(...skipping 4165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4176 { 4176 {
4177 HCERTSTORE hStore = NULL; 4177 HCERTSTORE hStore = NULL;
4178 PCCERT_CONTEXT pCertCtx = NULL; 4178 PCCERT_CONTEXT pCertCtx = NULL;
4179 PyObject *keyusage = NULL, *cert = NULL, *enc = NULL, *tup = NULL; 4179 PyObject *keyusage = NULL, *cert = NULL, *enc = NULL, *tup = NULL;
4180 PyObject *result = NULL; 4180 PyObject *result = NULL;
4181 4181
4182 result = PyList_New(0); 4182 result = PyList_New(0);
4183 if (result == NULL) { 4183 if (result == NULL) {
4184 return NULL; 4184 return NULL;
4185 } 4185 }
4186 hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); 4186 hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL,
4187 CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_M ACHINE,
4188 store_name);
4187 if (hStore == NULL) { 4189 if (hStore == NULL) {
4188 Py_DECREF(result); 4190 Py_DECREF(result);
4189 return PyErr_SetFromWindowsErr(GetLastError()); 4191 return PyErr_SetFromWindowsErr(GetLastError());
4190 } 4192 }
4191 4193
4192 while (pCertCtx = CertEnumCertificatesInStore(hStore, pCertCtx)) { 4194 while (pCertCtx = CertEnumCertificatesInStore(hStore, pCertCtx)) {
4193 cert = PyBytes_FromStringAndSize((const char*)pCertCtx->pbCertEncoded, 4195 cert = PyBytes_FromStringAndSize((const char*)pCertCtx->pbCertEncoded,
4194 pCertCtx->cbCertEncoded); 4196 pCertCtx->cbCertEncoded);
4195 if (!cert) { 4197 if (!cert) {
4196 Py_CLEAR(result); 4198 Py_CLEAR(result);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
4262 { 4264 {
4263 HCERTSTORE hStore = NULL; 4265 HCERTSTORE hStore = NULL;
4264 PCCRL_CONTEXT pCrlCtx = NULL; 4266 PCCRL_CONTEXT pCrlCtx = NULL;
4265 PyObject *crl = NULL, *enc = NULL, *tup = NULL; 4267 PyObject *crl = NULL, *enc = NULL, *tup = NULL;
4266 PyObject *result = NULL; 4268 PyObject *result = NULL;
4267 4269
4268 result = PyList_New(0); 4270 result = PyList_New(0);
4269 if (result == NULL) { 4271 if (result == NULL) {
4270 return NULL; 4272 return NULL;
4271 } 4273 }
4272 hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); 4274 hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL,
4275 CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_M ACHINE,
4276 store_name);
4273 if (hStore == NULL) { 4277 if (hStore == NULL) {
4274 Py_DECREF(result); 4278 Py_DECREF(result);
4275 return PyErr_SetFromWindowsErr(GetLastError()); 4279 return PyErr_SetFromWindowsErr(GetLastError());
4276 } 4280 }
4277 4281
4278 while (pCrlCtx = CertEnumCRLsInStore(hStore, pCrlCtx)) { 4282 while (pCrlCtx = CertEnumCRLsInStore(hStore, pCrlCtx)) {
4279 crl = PyBytes_FromStringAndSize((const char*)pCrlCtx->pbCrlEncoded, 4283 crl = PyBytes_FromStringAndSize((const char*)pCrlCtx->pbCrlEncoded,
4280 pCrlCtx->cbCrlEncoded); 4284 pCrlCtx->cbCrlEncoded);
4281 if (!crl) { 4285 if (!crl) {
4282 Py_CLEAR(result); 4286 Py_CLEAR(result);
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
4772 return NULL; 4776 return NULL;
4773 4777
4774 libver = OPENSSL_VERSION_NUMBER; 4778 libver = OPENSSL_VERSION_NUMBER;
4775 parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); 4779 parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
4776 r = Py_BuildValue("IIIII", major, minor, fix, patch, status); 4780 r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
4777 if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r)) 4781 if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
4778 return NULL; 4782 return NULL;
4779 4783
4780 return m; 4784 return m;
4781 } 4785 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+