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G5RLIvVhc+1
D7mD7ve7a9FrdASr8KCl1mrLflHZKFkPQFquQaUCgYB2fc431vBL2mPk1KMw/wuT
JYK+HqiP73piOZCqvPE1kZegKkT3ZY2dcH5HWA2gdQ6fPGyUffnja4vTe0lSzbsN
la6IKeRMgObDQzPTKpWzDQZiHzGy/T5a7NXPeUvo5wnAU4c0zjHOp6nTXlB+s+6h
lJjW+NFsouaq0UBDGqW3SQKBgEYRTWuHrvVYrGSGC5iHWQNsrOTHY//iS8HN+J5Z
WHESnzoZW6xu7yn5AxjHTdaNCaC2xXkg4oKn9D2CvrPm4DPVzcjCKg2U3+TzZkUv
Nrok6+jo74VshWEJUTvM/PVu52QMiwmGpcHEoM0jceQJmE5abdkqI2A+mdCL/a9o
sw9dAoGAPxzIiKU606m7m8GKr3IuRjMPqwP7qC9HOdc+NXIyJqnK+nvwReCAIOEL
pzqLRw7mjUfdCJ5Gdx0TPYl8ckRKQAwuSWm4a8XaUCP73NCIe6e3lVn/29wsVtTI
2XQsAKrvBHQ9834wJ6XEn4j6LnUxbLIiSdV8wJqOhjRxEZKwu4w=
-----END RSA PRIVATE KEY-----
"""
        key = Key(keyString)

        self.assertFalse(key.bogus())
예제 #2
0
    def test_valid_key(self):
        keyString = """
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAgxWvHJCNGD8YWKKdQ3m0bMc7RjOWyoopeqAJ72DkOg41HFfU
g1rGmaQcu0OanUx4HWOcT5xevypm2jUIpUnV3BAt9vLI3oSxe8v8iivHHYmcCIFL
pP5SPNTcmn2A1O9jDtUcG6SRMBeERTBUU0GuRad7Rg0lSYOUCkvdg1XC8gLVror+
y1hE1HdPMfW7mW5aTZ+qWnNrUuFL6WC0nvL4JKOi1LyQlZlimIWxILIjs2M2s6na
mnfht2hdhf6of4cpGdOTgQ4YgPg4hlSb51yyq9KSJoova7GAvcGB2jBlvm2No7vp
j7UG+/XTivtXNPgjV3SHzSZxypnws9Kurd0QLQIDAQABAoIBAFl0js/7hY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RjMPqwP7qC9HOdc+NXIyJqnK+nvwReCAIOEL
pzqLRw7mjUfdCJ5Gdx0TPYl8ckRKQAwuSWm4a8XaUCP73NCIe6e3lVn/29wsVtTI
2XQsAKrvBHQ9834wJ6XEn4j6LnUxbLIiSdV8wJqOhjRxEZKwu4w=
-----END RSA PRIVATE KEY-----
"""
        key = Key(keyString)

        self.assertFalse(key.bogus())
예제 #3
0
    def verify_valid_entitlement(self):
        """
        Verify that a valid entitlement was processed.

        @return: True if valid, False otherwise.
        """
        ent_cert = EntitlementCertificate(self.get_cert_content())
        ent_key = Key(self.get_key_content())
        if ent_cert.bogus() or ent_key.bogus():
            return False
        return True
예제 #4
0
    def verify_valid_entitlement(self):
        """
        Verify that a valid entitlement was processed.

        @return: True if valid, False otherwise.
        """
        ent_cert = EntitlementCertificate(self.get_cert_content())
        ent_key = Key(self.get_key_content())
        if ent_cert.bogus() or ent_key.bogus():
            return False
        return True
예제 #5
0
    def _check_key(self, cert):
        """
        If the new key file (SERIAL-key.pem) does not exist, check for
        the old style (key.pem), and if found write it out as the new style.

        Return false if neither is found, indicating we have no key for this
        certificate.

        See bz #711133.
        """
        key_path = "%s/%s-key.pem" % (self.path, cert.serialNumber())
        if not os.access(key_path, os.R_OK):
            # read key from old key path
            old_key_path = "%s/key.pem" % self.path

            # if we don't have a new style or old style key, consider the
            # cert invalid
            if not os.access(old_key_path, os.R_OK):
                return False

            # write the key/cert out again in new style format
            key = Key.read(old_key_path)
            cert_writer = Writer()
            cert_writer.write(key, cert)
        return True
    def _check_key(self, cert):
        """
        If the new key file (SERIAL-key.pem) does not exist, check for
        the old style (key.pem), and if found write it out as the new style.

        Return false if neither is found, indicating we have no key for this
        certificate.

        See bz #711133.
        """
        key_path = cert.key_path()
        if not os.access(key_path, os.R_OK):
            # read key from old key path
            old_key_path = "%s/key.pem" % self.path

            # if we don't have a new style or old style key, consider the
            # cert invalid
            if not os.access(old_key_path, os.R_OK):
                return False

            # write the key/cert out again in new style format
            key = Key.read(old_key_path)
            cert_writer = Writer(self)
            cert_writer.write(key, cert)
        return True
예제 #7
0
    def build(self, bundle):
        keypem = bundle['key']
        crtpem = bundle['cert']
        key = Key(keypem)

        cert = create_from_pem(crtpem)
        return (key, cert)
예제 #8
0
    def verify_valid_entitlement(self):
        """
        Verify that a valid entitlement was processed.

        @return: True if valid, False otherwise.
        """
        try:
            cert = self.get_cert()
            # Don't want to check class explicitly, instead we'll look for
            # order info, which only an entitlement cert could have:
            if not hasattr(cert, 'order'):
                return False
        except CertificateException:
            return False
        ent_key = Key(self.get_key_content())
        if ent_key.bogus():
            return False
        return True
예제 #9
0
    def verify_valid_entitlement(self):
        """
        Verify that a valid entitlement was processed.

        @return: True if valid, False otherwise.
        """
        try:
            cert = self.get_cert()
            # Don't want to check class explicitly, instead we'll look for
            # order info, which only an entitlement cert could have:
            if not hasattr(cert, 'order'):
                return False
        except CertificateException:
            return False
        ent_key = Key(self.get_key_content())
        if ent_key.bogus():
            return False
        return True
예제 #10
0
    def build_cert(self, bundle):
        """Split a cert bundle into a EntitlementCertificate and a Key."""
        keypem = bundle['key']
        crtpem = bundle['cert']

        key = Key(keypem)
        cert = create_from_pem(crtpem)

        return (key, cert)
예제 #11
0
 def test_garbage_key(self):
     keyString = "Some Garbage Data"
     key = Key(keyString)
     self.assertTrue(key.bogus())
예제 #12
0
 def test_empty_key(self):
     keyString = ""
     key = Key(keyString)
     self.assertTrue(key.bogus())
예제 #13
0
 def test_garbage_key(self):
     keyString = "Some Garbage Data"
     key = Key(keyString)
     self.assertTrue(key.bogus())
예제 #14
0
 def test_empty_key(self):
     keyString = ""
     key = Key(keyString)
     self.assertTrue(key.bogus())