def tls_alpn_challenge_put_pem(domain, identifier): log('Adding TLS ALPN challenge for domain {0} and identifier {1} (PEM certificate and key)'.format(domain, identifier)) key, cert_challenge = _get_alpn_key_cert_from_pem_chain(domain, identifier, request.data) cert_normal = gen_ss_cert(key, [domain], [], []) # Start/modify TLS-ALPN-01 challenge server tls_alpn_server.add(domain, key, cert_normal, cert_challenge) tls_alpn_server.update() return 'ok'
def tls_alpn_challenge_put_b64(domain, identifier): log('Adding TLS ALPN challenge for domain {0} and identifier {1} (Base64 encoded DER value)'.format(domain, identifier)) key, cert_challenge = _get_alpn_key_cert_from_der_value(domain, identifier, request.data) cert_normal = gen_ss_cert(key, [domain], [], []) # Start/modify TLS-ALPN-01 challenge server tls_alpn_server.add(domain, key, cert_normal, cert_challenge) tls_alpn_server.update() return 'ok'
def tls_alpn_challenge_put_pem(domain, identifier): log('Adding TLS ALPN challenge for domain {0} and identifier {1} (PEM certificate and key)'.format(domain, identifier)) key, cert_challenge = _get_alpn_key_cert_from_pem_chain(domain, identifier, request.data) cert_normal = gen_ss_cert(key, [domain], [], []) # Start/modify TLS-ALPN-01 challenge server tls_alpn_server.add(domain, key, cert_normal, cert_challenge) tls_alpn_server.update() return 'ok'
def tls_alpn_challenge_put_b64(domain, identifier): log('Adding TLS ALPN challenge for domain {0} and identifier {1} (Base64 encoded DER value)'.format(domain, identifier)) key, cert_challenge = _get_alpn_key_cert_from_der_value(domain, identifier, request.data) cert_normal = gen_ss_cert(key, [domain], [], []) # Start/modify TLS-ALPN-01 challenge server tls_alpn_server.add(domain, key, cert_normal, cert_challenge) tls_alpn_server.update() return 'ok'
def _get_alpn_key_cert_from_der_value(domain, identifier, data): der_value = b"DER:0420" + codecs.encode(base64.standard_b64decode(data), 'hex') domains = [] ips = [] if identifier.upper().startswith('DNS:'): domains.append(identifier[4:]) elif identifier.upper().startswith('IP:'): ips.append(identifier[3:]) # Create private key key = crypto.PKey() key.generate_key(crypto.TYPE_RSA, 2048) # Create self-signed certificates acme_extension = crypto.X509Extension(b"1.3.6.1.5.5.7.1.31", critical=True, value=der_value) cert_challenge = gen_ss_cert(key, domains, ips, extensions=[acme_extension]) return key, cert_challenge
def _get_alpn_key_cert_from_der_value(domain, identifier, data): der_value = b"DER:0420" + codecs.encode(base64.standard_b64decode(data), 'hex') domains = [] ips = [] if identifier.upper().startswith('DNS:'): domains.append(identifier[4:]) elif identifier.upper().startswith('IP:'): ips.append(identifier[3:]) # Create private key key = crypto.PKey() key.generate_key(crypto.TYPE_RSA, 2048) # Create self-signed certificates acme_extension = crypto.X509Extension(b"1.3.6.1.5.5.7.1.31", critical=True, value=der_value) cert_challenge = gen_ss_cert(key, domains, ips, extensions=[acme_extension]) return key, cert_challenge