-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#560] Implement workaround for memory leak in CertificateChainVerifier
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/plugins_tests/certificate_info/test_cert_chain_analyzer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from sslyze.plugins.certificate_info.trust_stores.trust_store_repository import TrustStoresRepository | ||
from sslyze.plugins.certificate_info._cert_chain_analyzer import ( | ||
_cache_for_trusted_certificates_per_file, | ||
_convert_and_cache_pem_certs_to_x509s, | ||
) | ||
|
||
|
||
class TestMemoryLeakWorkaroundWithX509Cache: | ||
def test(self): | ||
# Given a path to a file with a list of PEM certificates | ||
trusted_certificates_path = TrustStoresRepository.get_default().get_main_store().path | ||
|
||
# And the file's content has not been cached yet | ||
assert trusted_certificates_path not in _cache_for_trusted_certificates_per_file | ||
|
||
# When converting the content of the file to X509 objects | ||
certs_as_x509s = _convert_and_cache_pem_certs_to_x509s(trusted_certificates_path) | ||
|
||
# It succeeds, and the x509 objects were cached | ||
assert certs_as_x509s | ||
assert trusted_certificates_path in _cache_for_trusted_certificates_per_file |