MCPcopy Index your code
hub / github.com/RustPython/RustPython / collect_ssl

Function collect_ssl

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

copy_attributesFunction · 0.85
hasattrFunction · 0.85
extendMethod · 0.45

Tested by

no test coverage detected