def test_gen_verify_cert_negative_with_wrong_key(self):
     cert = self.msg.gen_cert(self.chall, self.domain, self.key)
     key = test_util.load_rsa_private_key('rsa256_key.pem').public_key()
     self.assertFalse(
         self.msg.verify_cert(self.chall,
                              self.domain,
                              public_key=key,
                              cert=cert))
示例#2
0
    def setUp(self):
        from acme.challenges import DVSNIResponse
        # pylint: disable=invalid-name
        s = '9dbjsl3gTAtOnEtKFEmhS6Mj-ajNjDcOmRkp3Lfzm3c'
        self.msg = DVSNIResponse(s=jose.decode_b64jose(s))
        self.jmsg = {
            'resource': 'challenge',
            'type': 'dvsni',
            's': s,
        }

        from acme.challenges import DVSNI
        self.chall = DVSNI(
            r=jose.decode_b64jose('Tyq0La3slT7tqQ0wlOiXnCY2vyez7Zo5blgPJ1xt5xI'),
            nonce=jose.decode_b64jose('a82d5ff8ef740d12881f6d3c2277ab2e'))
        self.z = (b'38e612b0397cc2624a07d351d7ef50e4'
                  b'6134c0213d9ed52f7d7c611acaeed41b')
        self.domain = 'foo.com'
        self.key = test_util.load_pyopenssl_private_key('rsa512_key.pem')
        self.public_key = test_util.load_rsa_private_key(
            'rsa512_key.pem').public_key()
    def setUp(self):
        from acme.challenges import DVSNIResponse
        # pylint: disable=invalid-name
        s = '9dbjsl3gTAtOnEtKFEmhS6Mj-ajNjDcOmRkp3Lfzm3c'
        self.msg = DVSNIResponse(s=jose.decode_b64jose(s))
        self.jmsg = {
            'resource': 'challenge',
            'type': 'dvsni',
            's': s,
        }

        from acme.challenges import DVSNI
        self.chall = DVSNI(
            r=jose.decode_b64jose(
                'Tyq0La3slT7tqQ0wlOiXnCY2vyez7Zo5blgPJ1xt5xI'),
            nonce=jose.decode_b64jose('a82d5ff8ef740d12881f6d3c2277ab2e'))
        self.z = (b'38e612b0397cc2624a07d351d7ef50e4'
                  b'6134c0213d9ed52f7d7c611acaeed41b')
        self.domain = 'foo.com'
        self.key = test_util.load_pyopenssl_private_key('rsa512_key.pem')
        self.public_key = test_util.load_rsa_private_key(
            'rsa512_key.pem').public_key()
示例#4
0
"""Tests for acme.messages."""
import unittest

import mock

from acme import challenges
from acme import jose
from acme import test_util


CERT = test_util.load_cert('cert.der')
CSR = test_util.load_csr('csr.der')
KEY = test_util.load_rsa_private_key('rsa512_key.pem')


class ErrorTest(unittest.TestCase):
    """Tests for acme.messages.Error."""

    def setUp(self):
        from acme.messages import Error
        self.error = Error(detail='foo', typ='malformed', title='title')
        self.jobj = {'detail': 'foo', 'title': 'some title'}

    def test_typ_prefix(self):
        self.assertEqual('malformed', self.error.typ)
        self.assertEqual(
            'urn:acme:error:malformed', self.error.to_partial_json()['type'])
        self.assertEqual(
            'malformed', self.error.from_json(self.error.to_partial_json()).typ)

    def test_typ_decoder_missing_prefix(self):
示例#5
0
"""Tests for acme.jose.jwa."""
import unittest

from acme import test_util

from acme.jose import errors

RSA256_KEY = test_util.load_rsa_private_key('rsa256_key.pem')
RSA512_KEY = test_util.load_rsa_private_key('rsa512_key.pem')
RSA1024_KEY = test_util.load_rsa_private_key('rsa1024_key.pem')


class JWASignatureTest(unittest.TestCase):
    """Tests for acme.jose.jwa.JWASignature."""
    def setUp(self):
        from acme.jose.jwa import JWASignature

        class MockSig(JWASignature):
            # pylint: disable=missing-docstring,too-few-public-methods
            # pylint: disable=abstract-class-not-used
            def sign(self, key, msg):
                raise NotImplementedError()  # pragma: no cover

            def verify(self, key, msg, sig):
                raise NotImplementedError()  # pragma: no cover

        # pylint: disable=invalid-name
        self.Sig1 = MockSig('Sig1')
        self.Sig2 = MockSig('Sig2')

    def test_eq(self):
示例#6
0
import copy
import os
import re
import shutil
import tarfile

from acme import jose
from acme import test_util
from certbot import constants

from certbot_compatibility_test import errors

_KEY_BASE = "rsa1024_key.pem"
KEY_PATH = test_util.vector_path(_KEY_BASE)
KEY = test_util.load_pyopenssl_private_key(_KEY_BASE)
JWK = jose.JWKRSA(key=test_util.load_rsa_private_key(_KEY_BASE))
IP_REGEX = re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")


def create_le_config(parent_dir):
    """Sets up LE dirs in parent_dir and returns the config dict"""
    config = copy.deepcopy(constants.CLI_DEFAULTS)

    le_dir = os.path.join(parent_dir, "certbot")
    config["config_dir"] = os.path.join(le_dir, "config")
    config["work_dir"] = os.path.join(le_dir, "work")
    config["logs_dir"] = os.path.join(le_dir, "logs_dir")
    os.makedirs(config["config_dir"])
    os.mkdir(config["work_dir"])
    os.mkdir(config["logs_dir"])
示例#7
0
"""Tests for acme.challenges."""
import unittest

import josepy as jose
import mock
import requests

from six.moves.urllib import parse as urllib_parse  # pylint: disable=relative-import

from acme import test_util

CERT = test_util.load_comparable_cert('cert.pem')
KEY = jose.JWKRSA(key=test_util.load_rsa_private_key('rsa512_key.pem'))


class ChallengeTest(unittest.TestCase):

    def test_from_json_unrecognized(self):
        from acme.challenges import Challenge
        from acme.challenges import UnrecognizedChallenge
        chall = UnrecognizedChallenge({"type": "foo"})
        # pylint: disable=no-member
        self.assertEqual(chall, Challenge.from_json(chall.jobj))


class UnrecognizedChallengeTest(unittest.TestCase):

    def setUp(self):
        from acme.challenges import UnrecognizedChallenge
        self.jobj = {"type": "foo"}
        self.chall = UnrecognizedChallenge(self.jobj)
示例#8
0
"""Tests for acme.jose.jwa."""
import unittest

from acme import test_util

from acme.jose import errors


RSA256_KEY = test_util.load_rsa_private_key('rsa256_key.pem')
RSA512_KEY = test_util.load_rsa_private_key('rsa512_key.pem')
RSA1024_KEY = test_util.load_rsa_private_key('rsa1024_key.pem')


class JWASignatureTest(unittest.TestCase):
    """Tests for acme.jose.jwa.JWASignature."""

    def setUp(self):
        from acme.jose.jwa import JWASignature

        class MockSig(JWASignature):
            # pylint: disable=missing-docstring,too-few-public-methods
            # pylint: disable=abstract-class-not-used
            def sign(self, key, msg):
                raise NotImplementedError()  # pragma: no cover

            def verify(self, key, msg, sig):
                raise NotImplementedError()  # pragma: no cover

        # pylint: disable=invalid-name
        self.Sig1 = MockSig('Sig1')
        self.Sig2 = MockSig('Sig2')
示例#9
0
 def test_gen_verify_cert_negative_with_wrong_key(self):
     cert = self.msg.gen_cert(self.chall, self.domain, self.key)
     key = test_util.load_rsa_private_key('rsa256_key.pem').public_key()
     self.assertFalse(self.msg.verify_cert(
         self.chall, self.domain, public_key=key, cert=cert))
示例#10
0
 def setUp(self):
     # test_utl.load_rsa_private_key return ComparableRSAKey
     self.key = test_util.load_rsa_private_key('rsa256_key.pem')
     self.key_same = test_util.load_rsa_private_key('rsa256_key.pem')
     self.key2 = test_util.load_rsa_private_key('rsa512_key.pem')
示例#11
0
 def setUp(self):
     # test_utl.load_rsa_private_key return ComparableRSAKey
     self.key = test_util.load_rsa_private_key('rsa256_key.pem')
     self.key_same = test_util.load_rsa_private_key('rsa256_key.pem')
     self.key2 = test_util.load_rsa_private_key('rsa512_key.pem')
"""Tests for acme.challenges."""
import unittest

import mock
import OpenSSL
import requests

from six.moves.urllib import parse as urllib_parse  # pylint: disable=import-error

from acme import errors
from acme import jose
from acme import test_util
from acme.dns_resolver import DNS_REQUIREMENT

CERT = test_util.load_comparable_cert('cert.pem')
KEY = jose.JWKRSA(key=test_util.load_rsa_private_key('rsa512_key.pem'))


class ChallengeTest(unittest.TestCase):

    def test_from_json_unrecognized(self):
        from acme.challenges import Challenge
        from acme.challenges import UnrecognizedChallenge
        chall = UnrecognizedChallenge({"type": "foo"})
        # pylint: disable=no-member
        self.assertEqual(chall, Challenge.from_json(chall.jobj))


class UnrecognizedChallengeTest(unittest.TestCase):

    def setUp(self):
示例#13
0
import re
import shutil
import socket
import tarfile

from acme import jose
from acme import test_util
from letsencrypt import constants

from letsencrypt_compatibility_test import errors


_KEY_BASE = "rsa1024_key.pem"
KEY_PATH = test_util.vector_path(_KEY_BASE)
KEY = test_util.load_pyopenssl_private_key(_KEY_BASE)
JWK = jose.JWKRSA(key=test_util.load_rsa_private_key(_KEY_BASE))
IP_REGEX = re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")


def create_le_config(parent_dir):
    """Sets up LE dirs in parent_dir and returns the config dict"""
    config = copy.deepcopy(constants.CLI_DEFAULTS)

    le_dir = os.path.join(parent_dir, "letsencrypt")
    config["config_dir"] = os.path.join(le_dir, "config")
    config["work_dir"] = os.path.join(le_dir, "work")
    config["logs_dir"] = os.path.join(le_dir, "logs_dir")
    os.makedirs(config["config_dir"])
    os.mkdir(config["work_dir"])
    os.mkdir(config["logs_dir"])