示例#1
0
 def test_cli_sign_and_verify_ecdsa_pkcs8_sha512(self):
     src = get_data_fn("cli-sign-and-verify.jar")
     key_alias = "SAMPLE3"
     cert = get_data_fn("ec-cert.pem")
     key = get_data_fn("ec-key.pem")
     with NamedTemporaryFile() as tmp_jar:
         copyfile(src, tmp_jar.name)
         cli_sign_jar([tmp_jar.name, cert, key, key_alias])
         self.verify_wrap(
             cert, tmp_jar.name,
             "Verification of JAR which we just signed failed")
示例#2
0
 def test_cli_sign_new_file_and_verify(self):
     src = get_data_fn("cli-sign-and-verify.jar")
     #dst = get_data_fn("tmp.jar")
     key_alias = "SAMPLE3"
     cert = get_data_fn("javatools-cert.pem")
     key = get_data_fn("javatools.pem")
     with NamedTemporaryFile() as tmp_jar, NamedTemporaryFile() as dst:
         copyfile(src, tmp_jar.name)
         cli_sign_jar([tmp_jar.name, cert, key, key_alias, "-o", dst.name])
         self.verify_wrap(
             cert, dst.name,
             "Verification of JAR which we just signed failed")
示例#3
0
 def test_cli_sign_and_verify(self):
     src = get_data_fn("cli-sign-and-verify.jar")
     key_alias = "SAMPLE3"
     cert = get_data_fn("javatools-cert.pem")
     key = get_data_fn("javatools.pem")
     with NamedTemporaryFile() as tmp_jar:
         copyfile(src, tmp_jar.name)
         cli_sign_jar(None, tmp_jar.name, cert, key, key_alias)
         error_message = verify(cert, tmp_jar.name, key_alias)
         self.assertIsNone(error_message,
                           "Verification of JAR which we just signed failed: %s"
                           % error_message)
示例#4
0
 def test_cli_sign_and_verify_ecdsa_pkcs8_sha512(self):
     src = get_data_fn("cli-sign-and-verify.jar")
     key_alias = "SAMPLE3"
     cert = get_data_fn("ec-cert.pem")
     key = get_data_fn("ec-key.pem")
     with NamedTemporaryFile() as tmp_jar:
         copyfile(src, tmp_jar.name)
         cli_sign_jar([tmp_jar.name, cert, key, key_alias])
         error_message = verify(cert, tmp_jar.name, key_alias)
         self.assertIsNone(error_message,
                           "Verification of JAR which we just signed failed: %s"
                           % error_message)
示例#5
0
 def test_cli_sign_and_verify(self):
     src = get_data_fn(
         "test_jarutil/test_cli_sign_and_verify__cli-sign-and-verify.jar")
     key_alias = "SAMPLE3"
     cert = get_data_fn(
         "test_jarutil/test_cli_sign_and_verify__javatools-cert.pem")
     key = get_data_fn(
         "test_jarutil/test_cli_sign_and_verify__javatools.pem")
     with NamedTemporaryFile() as tmp_jar:
         copyfile(src, tmp_jar.name)
         cli_sign_jar([tmp_jar.name, cert, key, key_alias])
         self.verify_wrap(
             cert, tmp_jar.name,
             "Verification of JAR which we just signed failed")
示例#6
0
 def test_sign_with_certchain_and_verify(self):
     src = get_data_fn(
         "test_jarutil/test_sign_with_certchain_and_verify__certchain-data.jar"
     )
     key_alias = "SIGNING"
     signing_cert = get_data_fn(
         "test_jarutil/test_sign_with_certchain_and_verify__certchain-signing.pem"
     )
     key = get_data_fn(
         "test_jarutil/test_sign_with_certchain_and_verify__certchain-signing-key.pem"
     )
     intermediate_cert = get_data_fn(
         "test_jarutil/test_sign_with_certchain_and_verify__certchain-intermediate.pem"
     )
     root_cert = get_data_fn(
         "test_jarutil/test_sign_with_certchain_and_verify__certchain-root.pem"
     )
     with NamedTemporaryFile() as tmp_jar:
         copyfile(src, tmp_jar.name)
         self.assertEqual(
             0,
             cli_sign_jar([
                 "-c", root_cert, "-c", intermediate_cert, tmp_jar.name,
                 signing_cert, key, key_alias
             ]), "Signing with embedding a chain of certificates failed")
         self.verify_wrap(
             root_cert, tmp_jar.name,
             "Verification of JAR which we signed embedding chain of certificates failed"
         )
示例#7
0
    def test_sign_with_certchain_and_verify(self):
        src = get_data_fn("certchain-data.jar")
        key_alias = "SIGNING"
        signing_cert = get_data_fn("certchain-signing.pem")
        key = get_data_fn("certchain-signing-key.pem")
        intermediate_cert = get_data_fn("certchain-intermediate.pem")
        root_cert = get_data_fn("certchain-root.pem")
        with NamedTemporaryFile() as tmp_jar:
            copyfile(src, tmp_jar.name)
            self.assertEqual(0, cli_sign_jar(
                ["-c", root_cert, "-c", intermediate_cert,
                 tmp_jar.name, signing_cert, key, key_alias]),
                "Signing with embedding a chain of certificates failed")
            error_message = verify(root_cert, tmp_jar.name, key_alias)
            self.assertIsNone(error_message,
                "Verification of JAR which we signed embedding chain of certificates failed: %s"
                % error_message)

#
# The end.