From 5af1b0aaeb1e91b8838291afe925c2c728e63290 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Mon, 24 Apr 2023 13:21:43 -0500 Subject: [PATCH] Test out memory limiting to see if we can trip the limit --- src/truststore/_macos.py | 4 ++-- src/truststore/_windows.py | 4 ++-- tests/test_memory.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/truststore/_macos.py b/src/truststore/_macos.py index 7dc440b..731abd6 100644 --- a/src/truststore/_macos.py +++ b/src/truststore/_macos.py @@ -389,13 +389,13 @@ def _verify_peercerts_impl( ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks), ) CoreFoundation.CFArrayAppendValue(policies, ssl_policy) - CoreFoundation.CFRelease(ssl_policy) + # CoreFoundation.CFRelease(ssl_policy) revocation_policy = Security.SecPolicyCreateRevocation( kSecRevocationUseAnyAvailableMethod | kSecRevocationRequirePositiveResponse ) CoreFoundation.CFArrayAppendValue(policies, revocation_policy) - CoreFoundation.CFRelease(revocation_policy) + # CoreFoundation.CFRelease(revocation_policy) elif ssl_context.verify_flags & ssl.VERIFY_CRL_CHECK_LEAF: raise NotImplementedError("VERIFY_CRL_CHECK_LEAF not implemented for macOS") diff --git a/src/truststore/_windows.py b/src/truststore/_windows.py index 3de4960..3b6e77f 100644 --- a/src/truststore/_windows.py +++ b/src/truststore/_windows.py @@ -396,9 +396,9 @@ def _verify_peercerts_impl( else: raise finally: - CertCloseStore(hIntermediateCertStore, 0) + # CertCloseStore(hIntermediateCertStore, 0) if pCertContext: - CertFreeCertificateContext(pCertContext) + # CertFreeCertificateContext(pCertContext) def _get_and_verify_cert_chain( diff --git a/tests/test_memory.py b/tests/test_memory.py index a56b404..c3eb85a 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -22,9 +22,9 @@ async def test_memory_limit(server: Server) -> None: def run_requests(): ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) - for _ in range(10000): + for _ in range(1000): with urllib3.PoolManager(ssl_context=ctx) as http: - http.request("GET", server.base_url) + http.request("HEAD", server.base_url) http.clear() # Close connections so we get new ones. thread = asyncio.to_thread(run_requests)