equal
deleted
inserted
replaced
170 |
170 |
171 # CertCreateCertificateContext encodings |
171 # CertCreateCertificateContext encodings |
172 X509_ASN_ENCODING = 0x00000001 |
172 X509_ASN_ENCODING = 0x00000001 |
173 PKCS_7_ASN_ENCODING = 0x00010000 |
173 PKCS_7_ASN_ENCODING = 0x00010000 |
174 |
174 |
|
175 |
175 # These structs are only complete enough to achieve what we need. |
176 # These structs are only complete enough to achieve what we need. |
176 class CERT_CHAIN_CONTEXT(ctypes.Structure): |
177 class CERT_CHAIN_CONTEXT(ctypes.Structure): |
177 _fields_ = ( |
178 _fields_ = ( |
178 ("cbSize", _DWORD), |
179 ("cbSize", _DWORD), |
179 # CERT_TRUST_STATUS struct |
180 # CERT_TRUST_STATUS struct |
366 def _raiseoserror(name: bytes) -> NoReturn: |
367 def _raiseoserror(name: bytes) -> NoReturn: |
367 # Force the code to a signed int to avoid an 'int too large' error. |
368 # Force the code to a signed int to avoid an 'int too large' error. |
368 # See https://bugs.python.org/issue28474 |
369 # See https://bugs.python.org/issue28474 |
369 code = _kernel32.GetLastError() |
370 code = _kernel32.GetLastError() |
370 if code > 0x7FFFFFFF: |
371 if code > 0x7FFFFFFF: |
371 code -= 2 ** 32 |
372 code -= 2**32 |
372 err = ctypes.WinError(code=code) # pytype: disable=module-attr |
373 err = ctypes.WinError(code=code) # pytype: disable=module-attr |
373 raise OSError( |
374 raise OSError( |
374 err.errno, '%s: %s' % (encoding.strfromlocal(name), err.strerror) |
375 err.errno, '%s: %s' % (encoding.strfromlocal(name), err.strerror) |
375 ) |
376 ) |
376 |
377 |