MCPcopy Create free account
hub / github.com/apache/httpd / load_server_cert

Method load_server_cert

test/modules/md/md_cert_util.py:27–46  ·  view source on GitHub ↗
(cls, host_ip, host_port, host_name, tls=None, ciphers=None)

Source from the content-addressed store, hash-verified

25
26 @classmethod
27 def load_server_cert(cls, host_ip, host_port, host_name, tls=None, ciphers=None):
28 ctx = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
29 if tls is not None and tls != 1.0:
30 ctx.set_options(OpenSSL.SSL.OP_NO_TLSv1)
31 if tls is not None and tls != 1.1:
32 ctx.set_options(OpenSSL.SSL.OP_NO_TLSv1_1)
33 if tls is not None and tls != 1.2:
34 ctx.set_options(OpenSSL.SSL.OP_NO_TLSv1_2)
35 if tls is not None and tls != 1.3 and hasattr(OpenSSL.SSL, "OP_NO_TLSv1_3"):
36 ctx.set_options(OpenSSL.SSL.OP_NO_TLSv1_3)
37 if ciphers is not None:
38 ctx.set_cipher_list(ciphers)
39 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
40 connection = OpenSSL.SSL.Connection(ctx, s)
41 connection.connect((host_ip, int(host_port)))
42 connection.setblocking(1)
43 connection.set_tlsext_host_name(host_name.encode('utf-8'))
44 connection.do_handshake()
45 peer_cert = connection.get_peer_certificate()
46 return MDCertUtil(None, cert=peer_cert)
47
48 @classmethod
49 def parse_pem_cert(cls, text):

Callers 1

get_certMethod · 0.80

Calls 1

MDCertUtilClass · 0.85

Tested by

no test coverage detected