cpython: 9adcb61ea741 (original) (raw)

--- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -372,21 +372,45 @@ Certificate handling .. versionadded:: 3.4 -.. function:: enum_cert_store(store_name, cert_type='certificate') +.. function:: enum_certificates(store_name) Retrieve certificates from Windows' system cert store. store_name may be one of CA, ROOT or MY. Windows may provide additional cert

Availability: Windows. .. versionadded:: 3.4 +.. function:: enum_crls(store_name) +

+ Constants ^^^^^^^^^ @@ -657,15 +681,6 @@ Constants .. versionadded:: 3.4 -.. data:: X509_ASN_ENCODING

-

SSL Sockets -----------

--- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -144,7 +144,7 @@ else: _PROTOCOL_NAMES[PROTOCOL_TLSv1_2] = "TLSv1.2" if sys.platform == "win32":

from socket import getnameinfo as _getnameinfo from socket import socket, AF_INET, SOCK_STREAM, create_connection

--- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -528,29 +528,44 @@ class BasicSocketTests(unittest.TestCase self.assertEqual(paths.cafile, CERTFILE) self.assertEqual(paths.capath, CAPATH)

+

+

+

@unittest.skipUnless(sys.platform == "win32", "Windows specific")

-

def test_asn1object(self): expected = (129, 'serverAuth', 'TLS Web Server Authentication',

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -59,6 +59,10 @@ Core and Builtins Library ------- +- Issue #17134: Finalize interface to Windows' certificate store. Cert and

--- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3422,130 +3422,258 @@ PySSL_nid2obj(PyObject *self, PyObject return result; } - #ifdef _MSC_VER -PyDoc_STRVAR(PySSL_enum_cert_store_doc, -"enum_cert_store(store_name, cert_type='certificate') -> []\n[](#l5.10) + +static PyObject +certEncodingType(DWORD encodingType) +{

+

+} + +static PyObject* +parseKeyUsage(PCCERT_CONTEXT pCertCtx, DWORD flags) +{

+

+

+

+} + +PyDoc_STRVAR(PySSL_enum_certificates_doc, +"enum_certificates(store_name) -> []\n[](#l5.96) \n[](#l5.97) Retrieve certificates from Windows' cert store. store_name may be one of\n[](#l5.98) 'CA', 'ROOT' or 'MY'. The system may provide more cert storages, too.\n[](#l5.99) -cert_type must be either 'certificate' or 'crl'.\n[](#l5.100) +The function returns a list of (bytes, encoding_type, trust) tuples. The\n[](#l5.101) +encoding_type flag can be interpreted with X509_ASN_ENCODING or\n[](#l5.102) +PKCS_7_ASN_ENCODING. The trust setting is either a set of OIDs or the\n[](#l5.103) +boolean True."); + +static PyObject * +PySSL_enum_certificates(PyObject *self, PyObject *args, PyObject *kwds) +{

+

+

+

+

+} + +PyDoc_STRVAR(PySSL_enum_crls_doc, +"enum_crls(store_name) -> []\n[](#l5.186) +\n[](#l5.187) +Retrieve CRLs from Windows' cert store. store_name may be one of\n[](#l5.188) +'CA', 'ROOT' or 'MY'. The system may provide more cert storages, too.\n[](#l5.189) The function returns a list of (bytes, encoding_type) tuples. The\n[](#l5.190) encoding_type flag can be interpreted with X509_ASN_ENCODING or\n[](#l5.191) PKCS_7_ASN_ENCODING."); static PyObject * -PySSL_enum_cert_store(PyObject *self, PyObject *args, PyObject *kwds) +PySSL_enum_crls(PyObject *self, PyObject *args, PyObject *kwds) {

-

-

-

+

-

-

+

} -#endif + +#endif /* _MSC_VER / / List of functions exported by this module. */ @@ -3567,8 +3695,10 @@ static PyMethodDef PySSL_methods[] = { {"get_default_verify_paths", (PyCFunction)PySSL_get_default_verify_paths, METH_NOARGS, PySSL_get_default_verify_paths_doc}, #ifdef _MSC_VER

#endif {"txt2obj", (PyCFunction)PySSL_txt2obj, METH_VARARGS | METH_KEYWORDS, PySSL_txt2obj_doc}, @@ -3811,12 +3941,6 @@ PyInit__ssl(void) PyModule_AddIntConstant(m, "VERIFY_X509_STRICT", X509_V_FLAG_X509_STRICT); -#ifdef _MSC_VER

-#endif - /* Alert Descriptions from ssl.h / / note RESERVED constants no longer intended for use have been removed / / http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6 */