Exemplo n.º 1
0
def chall_to_challb(chall, status):  # pylint: disable=redefined-outer-name
    """Return ChallengeBody from Challenge."""
    kwargs = {
        "chall": chall,
        "uri": chall.typ + "_uri",
        "status": status,
    }

    if status == messages2.STATUS_VALID:
        kwargs.update({"validated": datetime.datetime.now()})

    return messages2.ChallengeBody(**kwargs)  # pylint: disable=star-args
Exemplo n.º 2
0
    def setUp(self):
        super(DvsniPerformTest, self).setUp()

        config = util.get_nginx_configurator(self.config_path, self.config_dir,
                                             self.work_dir, self.ssl_options)

        rsa256_file = pkg_resources.resource_filename(
            "letsencrypt.acme.jose", "testdata/rsa256_key.pem")
        rsa256_pem = pkg_resources.resource_string("letsencrypt.acme.jose",
                                                   "testdata/rsa256_key.pem")

        auth_key = le_util.Key(rsa256_file, rsa256_pem)

        from letsencrypt.client.plugins.nginx import dvsni
        self.sni = dvsni.NginxDvsni(config)

        self.achalls = [
            achallenges.DVSNI(challb=messages2.ChallengeBody(
                chall=challenges.DVSNI(
                    r="foo",
                    nonce="bar",
                ),
                uri="https://letsencrypt-ca.org/chall0_uri",
                status=messages2.Status("pending"),
            ),
                              domain="www.example.com",
                              key=auth_key),
            achallenges.DVSNI(challb=messages2.ChallengeBody(
                chall=challenges.DVSNI(
                    r="\xba\xa9\xda?<m\xaewmx\xea\xad\xadv\xf4\x02\xc9y\x80"
                    "\xe2_X\t\xe7\xc7\xa4\t\xca\xf7&\x945",
                    nonce="Y\xed\x01L\xac\x95\xf7pW\xb1\xd7"
                    "\xa1\xb2\xc5\x96\xba",
                ),
                uri="https://letsencrypt-ca.org/chall1_uri",
                status=messages2.Status("pending"),
            ),
                              domain="blah",
                              key=auth_key),
        ]
    def setUp(self):
        from letsencrypt.client.network2 import Network
        self.net = Network(
            new_reg_uri='https://www.letsencrypt-demo.org/acme/new-reg',
            key=KEY,
            alg=jose.RS256)
        self.response = mock.MagicMock(ok=True, status_code=httplib.OK)
        self.response.headers = {}
        self.response.links = {}

        self.identifier = messages2.Identifier(typ=messages2.IDENTIFIER_FQDN,
                                               value='example.com')

        # Registration
        self.contact = ('mailto:[email protected]', 'tel:+12025551212')
        reg = messages2.Registration(contact=self.contact,
                                     key=KEY.public(),
                                     recovery_token='t')
        self.regr = messages2.RegistrationResource(
            body=reg,
            uri='https://www.letsencrypt-demo.org/acme/reg/1',
            new_authzr_uri='https://www.letsencrypt-demo.org/acme/new-reg',
            terms_of_service='https://www.letsencrypt-demo.org/tos')

        # Authorization
        authzr_uri = 'https://www.letsencrypt-demo.org/acme/authz/1'
        challb = messages2.ChallengeBody(uri=(authzr_uri + '/1'),
                                         status=messages2.STATUS_VALID,
                                         chall=challenges.DNS(token='foo'))
        self.challr = messages2.ChallengeResource(body=challb,
                                                  authzr_uri=authzr_uri)
        self.authz = messages2.Authorization(identifier=messages2.Identifier(
            typ=messages2.IDENTIFIER_FQDN, value='example.com'),
                                             challenges=(challb, ),
                                             combinations=None,
                                             key=KEY.public())
        self.authzr = messages2.AuthorizationResource(
            body=self.authz,
            uri=authzr_uri,
            new_cert_uri='https://www.letsencrypt-demo.org/acme/new-cert')

        # Request issuance
        self.certr = messages2.CertificateResource(
            body=CERT,
            authzrs=(self.authzr, ),
            uri='https://www.letsencrypt-demo.org/acme/cert/1',
            cert_chain_uri='https://www.letsencrypt-demo.org/ca')