()
| 81 | |
| 82 | @staticmethod |
| 83 | def _ssl_context(): |
| 84 | if http_connection.context_set: |
| 85 | return http_connection.context |
| 86 | |
| 87 | cfg = Config() |
| 88 | cafile = cfg.ca_certs_file |
| 89 | if cafile == "": |
| 90 | cafile = None |
| 91 | certfile = cfg.ssl_client_cert_file or None |
| 92 | keyfile = cfg.ssl_client_key_file or None # the key may be embedded into cert file |
| 93 | |
| 94 | debug(u"Using ca_certs_file %s", cafile) |
| 95 | debug(u"Using ssl_client_cert_file %s", certfile) |
| 96 | debug(u"Using ssl_client_key_file %s", keyfile) |
| 97 | |
| 98 | if certfile is not None: |
| 99 | context = http_connection._ssl_client_auth_context(certfile, keyfile, cfg.check_ssl_certificate, cafile) |
| 100 | elif cfg.check_ssl_certificate: |
| 101 | context = http_connection._ssl_verified_context(cafile) |
| 102 | else: |
| 103 | context = http_connection._ssl_unverified_context(cafile) |
| 104 | |
| 105 | http_connection.context = context |
| 106 | http_connection.context_set = True |
| 107 | return context |
| 108 | |
| 109 | def forgive_wildcard_cert(self, cert, hostname): |
| 110 | """ |
no test coverage detected