def perform(self, chall_list): """Perform the challenge. .. warning:: For the StandaloneAuthenticator, because there is no convenient way to add additional requests, this should only be invoked once; subsequent invocations are an error. To perform validations for multiple independent sets of domains, a separate StandaloneAuthenticator should be instantiated. :param list chall_list: List of namedtuple types defined in :mod:`letsencrypt.client.challenge_util` (``DvsniChall``, etc.) :returns: ACME Challenge DVSNI responses following IAuthenticator interface. :rtype: :class:`list` of :class`dict` """ if self.child_pid or self.tasks: # We should not be willing to continue with perform # if there were existing pending challenges. raise ValueError(".perform() was called with pending tasks!") results_if_success = [] results_if_failure = [] if not chall_list or not isinstance(chall_list, list): raise ValueError(".perform() was called without challenge list") for chall in chall_list: if isinstance(chall, challenge_util.DvsniChall): # We will attempt to do it name, r_b64 = chall.domain, chall.r_b64 nonce, key = chall.nonce, chall.key cert, s_b64 = challenge_util.dvsni_gen_cert( name, r_b64, nonce, key) self.tasks[nonce + constants.DVSNI_DOMAIN_SUFFIX] = cert results_if_success.append({"type": "dvsni", "s": s_b64}) results_if_failure.append(None) else: # We will not attempt to do this challenge because it # is not a type we can handle results_if_success.append(False) results_if_failure.append(False) if not self.tasks: raise ValueError("nothing for .perform() to do") if self.already_listening(constants.DVSNI_CHALLENGE_PORT): # If we know a process is already listening on this port, # tell the user, and don't even attempt to bind it. (This # test is Linux-specific and won't indicate that the port # is bound if invoked on a different operating system.) return results_if_failure # Try to do the authentication; note that this creates # the listener subprocess via os.fork() if self.start_listener(constants.DVSNI_CHALLENGE_PORT, key): return results_if_success else: # TODO: This should probably raise a DVAuthError exception # rather than returning a list of None objects. return results_if_failure
def setUp(self): from letsencrypt.client.standalone_authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator() name, r_b64 = "example.com", jose.b64encode("x" * 32) test_key = pkg_resources.resource_string(__name__, "testdata/rsa256_key.pem") nonce, key = "abcdef", le_util.Key("foo", test_key) self.cert = challenge_util.dvsni_gen_cert(name, r_b64, nonce, key)[0] private_key = OpenSSL.crypto.load_privatekey( OpenSSL.crypto.FILETYPE_PEM, key.pem) self.authenticator.private_key = private_key self.authenticator.tasks = {"abcdef.acme.invalid": self.cert} self.authenticator.child_pid = 12345
def _setup_challenge_cert(self, chall): """Generate and write out challenge certificate.""" cert_path = self.get_cert_file(chall.nonce) # Register the path before you write out the file self.configurator.reverter.register_file_creation(True, cert_path) cert_pem, s_b64 = challenge_util.dvsni_gen_cert( chall.domain, chall.r_b64, chall.nonce, chall.key) # Write out challenge cert with open(cert_path, 'w') as cert_chall_fd: cert_chall_fd.write(cert_pem) return s_b64
def _setup_challenge_cert(self, chall): """Generate and write out challenge certificate.""" cert_path = self.get_cert_file(chall.nonce) # Register the path before you write out the file self.configurator.reverter.register_file_creation(True, cert_path) cert_pem, s_b64 = challenge_util.dvsni_gen_cert( chall.domain, chall.r_b64, chall.nonce, chall.key) # Write out challenge cert with open(cert_path, 'w') as cert_chall_fd: cert_chall_fd.write(cert_pem) return s_b64
def _call(self, filepath, name, r_b64, nonce, key): from letsencrypt.client.challenge_util import dvsni_gen_cert return dvsni_gen_cert(filepath, name, r_b64, nonce, key)
def _call(self, filepath, name, r_b64, nonce, key): from letsencrypt.client.challenge_util import dvsni_gen_cert return dvsni_gen_cert(filepath, name, r_b64, nonce, key)
def _call(cls, name, r_b64, nonce, key): from letsencrypt.client.challenge_util import dvsni_gen_cert return dvsni_gen_cert(name, r_b64, nonce, key)
def _call(cls, name, r_b64, nonce, key): from letsencrypt.client.challenge_util import dvsni_gen_cert return dvsni_gen_cert(name, r_b64, nonce, key)