Ejemplo n.º 1
0
    def test_perform(self, mock_restart, mock_dvsni_perform):
        # Only tests functionality specific to configurator.perform
        # Note: As more challenges are offered this will have to be expanded
        auth_key = le_util.Key(self.rsa256_file, self.rsa256_pem)
        achall1 = achallenges.DVSNI(
            chall=challenges.DVSNI(
                r="foo",
                nonce="bar"),
            domain="localhost", key=auth_key)
        achall2 = achallenges.DVSNI(
            chall=challenges.DVSNI(
                r="abc",
                nonce="def"),
            domain="example.com", key=auth_key)

        dvsni_ret_val = [
            challenges.DVSNIResponse(s="irrelevant"),
            challenges.DVSNIResponse(s="arbitrary"),
        ]

        mock_dvsni_perform.return_value = dvsni_ret_val
        responses = self.config.perform([achall1, achall2])

        self.assertEqual(mock_dvsni_perform.call_count, 1)
        self.assertEqual(responses, dvsni_ret_val)
        self.assertEqual(mock_restart.call_count, 1)
    def test_perform(self, mock_restart, mock_dvsni_perform):
        # Only tests functionality specific to configurator.perform
        # Note: As more challenges are offered this will have to be expanded
        auth_key = le_util.Key(self.rsa256_file, self.rsa256_pem)
        achall1 = achallenges.DVSNI(chall=challenges.DVSNI(
            r="jIq_Xy1mXGN37tb4L6Xj_es58fW571ZNyXekdZzhh7Q",
            nonce="37bc5eb75d3e00a19b4f6355845e5a18"),
                                    domain="encryption-example.demo",
                                    key=auth_key)
        achall2 = achallenges.DVSNI(chall=challenges.DVSNI(
            r="uqnaPzxtrndteOqtrXb0Asl5gOJfWAnnx6QJyvcmlDU",
            nonce="59ed014cac95f77057b1d7a1b2c596ba"),
                                    domain="letsencrypt.demo",
                                    key=auth_key)

        dvsni_ret_val = [
            challenges.DVSNIResponse(s="randomS1"),
            challenges.DVSNIResponse(s="randomS2"),
        ]

        mock_dvsni_perform.return_value = dvsni_ret_val
        responses = self.config.perform([achall1, achall2])

        self.assertEqual(mock_dvsni_perform.call_count, 1)
        self.assertEqual(responses, dvsni_ret_val)

        self.assertEqual(mock_restart.call_count, 1)
Ejemplo n.º 3
0
    def setUp(self):
        super(DvsniPerformTest, self).setUp()

        with mock.patch("letsencrypt.client.plugins.apache.configurator."
                        "mod_loaded") as mock_load:
            mock_load.return_value = True
            config = util.get_apache_configurator(
                self.config_path, self.config_dir, self.work_dir,
                self.ssl_options)

        from letsencrypt.client.plugins.apache import dvsni
        self.sni = dvsni.ApacheDvsni(config)

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

        auth_key = le_util.Key(rsa256_file, rsa256_pem)
        self.achalls = [
            achallenges.DVSNI(
                chall=challenges.DVSNI(
                    r="\x8c\x8a\xbf_-f\\cw\xee\xd6\xf8/\xa5\xe3\xfd\xeb9\xf1"
                      "\xf5\xb9\xefVM\xc9w\xa4u\x9c\xe1\x87\xb4",
                    nonce="7\xbc^\xb7]>\x00\xa1\x9bOcU\x84^Z\x18",
                ), domain="encryption-example.demo", key=auth_key),
            achallenges.DVSNI(
                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",
                ), domain="letsencrypt.demo", key=auth_key),
        ]
Ejemplo n.º 4
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.client.tests", "testdata/rsa256_key.pem")
        rsa256_pem = pkg_resources.resource_string("letsencrypt.client.tests",
                                                   "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(chall=challenges.DVSNI(
                r="foo",
                nonce="bar",
            ),
                              domain="www.example.com",
                              key=auth_key),
            achallenges.DVSNI(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",
            ),
                              domain="blah",
                              key=auth_key),
        ]
    def setUp(self):
        from letsencrypt.client.plugins.standalone.authenticator import \
            StandaloneAuthenticator
        self.authenticator = StandaloneAuthenticator(None)

        self.achall1 = achallenges.DVSNI(
            challb=acme_util.chall_to_challb(
                challenges.DVSNI(r="whee", nonce="foo"), "pending"),
            domain="foo.example.com", key=KEY)
        self.achall2 = achallenges.DVSNI(
            challb=acme_util.chall_to_challb(
                challenges.DVSNI(r="whee", nonce="bar"), "pending"),
            domain="bar.example.com", key=KEY)
        bad_achall = ("This", "Represents", "A Non-DVSNI", "Challenge")
        self.achalls = [self.achall1, self.achall2, bad_achall]
Ejemplo n.º 6
0
    def setUp(self):
        from letsencrypt.client.standalone_authenticator import \
            StandaloneAuthenticator
        self.authenticator = StandaloneAuthenticator()

        test_key = pkg_resources.resource_string(
            __name__, "testdata/rsa256_key.pem")
        self.key = le_util.Key("something", test_key)

        self.achall1 = achallenges.DVSNI(
            chall=challenges.DVSNI(r="whee", nonce="foo"),
            domain="foo.example.com", key=self.key)
        self.achall2 = achallenges.DVSNI(
            chall=challenges.DVSNI(r="whee", nonce="bar"),
            domain="bar.example.com", key=self.key)
        bad_achall = ("This", "Represents", "A Non-DVSNI", "Challenge")
        self.achalls = [self.achall1, self.achall2, bad_achall]
Ejemplo n.º 7
0
 def setUp(self):
     from letsencrypt.client.standalone_authenticator import \
         StandaloneAuthenticator
     self.authenticator = StandaloneAuthenticator()
     self.achall = achallenges.DVSNI(
         chall=challenges.DVSNI(r="whee", nonce="foononce"),
         domain="foo.example.com", key="key")
     self.authenticator.tasks = {self.achall.nonce_domain: "stuff"}
     self.authenticator.child_pid = 12345
Ejemplo n.º 8
0
    def setUp(self):
        self.chall = challenges.DVSNI(r="r_value", nonce="12345ABCDE")
        self.response = challenges.DVSNIResponse()
        key = le_util.Key(
            "path",
            pkg_resources.resource_string(
                __name__, os.path.join("testdata", "rsa256_key.pem")))

        from letsencrypt.client.achallenges import DVSNI
        self.achall = DVSNI(chall=self.chall, domain="example.com", key=key)
 def setUp(self):
     from letsencrypt.client.plugins.standalone.authenticator import \
         StandaloneAuthenticator
     self.authenticator = StandaloneAuthenticator(None)
     self.achall = achallenges.DVSNI(
         challb=acme_util.chall_to_challb(
             challenges.DVSNI(r="whee", nonce="foononce"), "pending"),
         domain="foo.example.com", key="key")
     self.authenticator.tasks = {self.achall.nonce_domain: "stuff"}
     self.authenticator.child_pid = 12345
 def setUp(self):
     from letsencrypt.client.plugins.standalone.authenticator import \
         StandaloneAuthenticator
     self.authenticator = StandaloneAuthenticator(None)
     self.cert = achallenges.DVSNI(
         challb=acme_util.chall_to_challb(
             challenges.DVSNI(r=("x" * 32), nonce="abcdef"), "pending"),
         domain="example.com", key=KEY).gen_cert_and_response()[0]
     self.authenticator.private_key = PRIVATE_KEY
     self.authenticator.tasks = {"abcdef.acme.invalid": self.cert}
     self.authenticator.parent_pid = 12345
Ejemplo n.º 11
0
 def setUp(self):
     from letsencrypt.client.standalone_authenticator import \
         StandaloneAuthenticator
     self.authenticator = StandaloneAuthenticator()
     test_key = pkg_resources.resource_string(
         __name__, "testdata/rsa256_key.pem")
     key = le_util.Key("foo", test_key)
     self.cert = achallenges.DVSNI(
         chall=challenges.DVSNI(r="x"*32, nonce="abcdef"),
         domain="example.com", key=key).gen_cert_and_response()[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
Ejemplo n.º 12
0
 def test_bad_cleanup(self):
     self.assertRaises(
         ValueError, self.authenticator.cleanup, [achallenges.DVSNI(
             chall=challenges.DVSNI(r="whee", nonce="badnonce"),
             domain="bad.example.com", key="key")])
Ejemplo n.º 13
0
import Crypto.PublicKey.RSA

from letsencrypt.acme import challenges
from letsencrypt.acme import jose

KEY = jose.HashableRSAKey(
    Crypto.PublicKey.RSA.importKey(
        pkg_resources.resource_string(
            "letsencrypt.client.tests",
            os.path.join("testdata", "rsa256_key.pem"))))

# Challenges
SIMPLE_HTTPS = challenges.SimpleHTTPS(
    token="evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA")
DVSNI = challenges.DVSNI(
    r="O*\xb4-\xad\xec\x95>\xed\xa9\r0\x94\xe8\x97\x9c&6\xbf'\xb3"
    "\xed\x9a9nX\x0f'\\m\xe7\x12",
    nonce="a82d5ff8ef740d12881f6d3c2277ab2e")
DNS = challenges.DNS(token="17817c66b60ce2e4012dfad92657527a")
RECOVERY_CONTACT = challenges.RecoveryContact(
    activation_url="https://example.ca/sendrecovery/a5bd99383fb0",
    success_url="https://example.ca/confirmrecovery/bb1b9928932",
    contact="c********[email protected]")
RECOVERY_TOKEN = challenges.RecoveryToken()
POP = challenges.ProofOfPossession(
    alg="RS256",
    nonce="xD\xf9\xb9\xdbU\xed\xaa\x17\xf1y|\x81\x88\x99 ",
    hints=challenges.ProofOfPossession.Hints(
        jwk=jose.JWKRSA(key=KEY.publickey()),
        cert_fingerprints=("93416768eb85e33adc4277f4c9acd63e7418fcfe",
                           "16d95b7b63f1972b980b14c20291f3c0d1855d95",
                           "48b46570d9fc6358108af43ad1649484def0debf"),