MCPcopy Index your code
hub / github.com/python/cpython / collect_ssl

Function collect_ssl

Lib/test/pythoninfo.py:578–628  ·  view source on GitHub ↗
(info_add)

Source from the content-addressed store, hash-verified

576
577
578def collect_ssl(info_add):
579 import os
580 try:
581 import ssl
582 except ImportError:
583 return
584 try:
585 import _ssl
586 except ImportError:
587 _ssl = None
588
589 def format_attr(attr, value):
590 if attr.startswith('OP_'):
591 return '%#8x' % value
592 else:
593 return value
594
595 attributes = (
596 'OPENSSL_VERSION',
597 'OPENSSL_VERSION_INFO',
598 'HAS_SNI',
599 'OP_ALL',
600 'OP_NO_TLSv1_1',
601 )
602 copy_attributes(info_add, ssl, 'ssl.%s', attributes, formatter=format_attr)
603
604 for name, ctx in (
605 ('SSLContext', ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)),
606 ('default_https_context', ssl._create_default_https_context()),
607 ('stdlib_context', ssl._create_stdlib_context()),
608 ):
609 attributes = (
610 'minimum_version',
611 'maximum_version',
612 'protocol',
613 'options',
614 'verify_mode',
615 )
616 copy_attributes(info_add, ctx, f'ssl.{name}.%s', attributes)
617
618 env_names = ["OPENSSL_CONF", "SSLKEYLOGFILE"]
619 if _ssl is not None and hasattr(_ssl, 'get_default_verify_paths'):
620 parts = _ssl.get_default_verify_paths()
621 env_names.extend((parts[0], parts[2]))
622
623 for name in env_names:
624 try:
625 value = os.environ[name]
626 except KeyError:
627 continue
628 info_add('ssl.environ[%s]' % name, value)
629
630
631def collect_socket(info_add):

Callers

nothing calls this directly

Calls 2

copy_attributesFunction · 0.85
extendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…