2017-06-05 03:16:40 +08:00
|
|
|
#! /usr/bin/env perl
|
2021-04-22 21:38:44 +08:00
|
|
|
# Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2017-06-05 03:16:40 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2017-06-05 03:16:40 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
|
|
|
|
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
2017-06-16 05:01:04 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
2017-06-05 03:16:40 +08:00
|
|
|
|
|
|
|
setup("test_x509_check_cert_pkey");
|
|
|
|
|
2021-03-22 23:23:24 +08:00
|
|
|
plan tests => 11;
|
2021-03-22 21:16:56 +08:00
|
|
|
|
|
|
|
sub src_file {
|
|
|
|
return srctop_file("test", "certs", shift);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub test_PEM_X509_INFO_read {
|
|
|
|
my $file = shift;
|
|
|
|
my $num = shift;
|
|
|
|
ok(run(test(["x509_check_cert_pkey_test", src_file($file), $num])),
|
|
|
|
"test_PEM_X509_INFO_read $file");
|
|
|
|
}
|
2017-06-05 03:16:40 +08:00
|
|
|
|
|
|
|
# rsa
|
|
|
|
ok(run(test(["x509_check_cert_pkey_test",
|
2021-03-22 21:16:56 +08:00
|
|
|
src_file("servercert.pem"),
|
|
|
|
src_file("serverkey.pem"), "cert", "ok"])));
|
2017-06-05 03:16:40 +08:00
|
|
|
# mismatched rsa
|
|
|
|
ok(run(test(["x509_check_cert_pkey_test",
|
2021-03-22 21:16:56 +08:00
|
|
|
src_file("servercert.pem"),
|
|
|
|
src_file("wrongkey.pem"), "cert", "failed"])));
|
2017-06-25 10:46:36 +08:00
|
|
|
SKIP: {
|
|
|
|
skip "DSA disabled", 1, if disabled("dsa");
|
|
|
|
# dsa
|
|
|
|
ok(run(test(["x509_check_cert_pkey_test",
|
2021-03-22 21:16:56 +08:00
|
|
|
src_file("server-dsa-cert.pem"),
|
|
|
|
src_file("server-dsa-key.pem"), "cert", "ok"])));
|
2017-06-25 10:46:36 +08:00
|
|
|
}
|
2017-06-05 03:16:40 +08:00
|
|
|
# ecc
|
2017-06-16 05:01:04 +08:00
|
|
|
SKIP: {
|
2021-03-22 21:16:56 +08:00
|
|
|
skip "EC disabled", 2 if disabled("ec");
|
2017-06-16 05:01:04 +08:00
|
|
|
ok(run(test(["x509_check_cert_pkey_test",
|
2021-03-22 21:16:56 +08:00
|
|
|
src_file("server-ecdsa-cert.pem"),
|
|
|
|
src_file("server-ecdsa-key.pem"), "cert", "ok"])));
|
|
|
|
|
|
|
|
test_PEM_X509_INFO_read("ec_privkey_with_chain.pem", "5");
|
|
|
|
|
2017-06-16 05:01:04 +08:00
|
|
|
}
|
2017-06-05 03:16:40 +08:00
|
|
|
# certificate request (rsa)
|
|
|
|
ok(run(test(["x509_check_cert_pkey_test",
|
2021-03-22 21:16:56 +08:00
|
|
|
src_file("x509-check.csr"),
|
|
|
|
src_file("x509-check-key.pem"), "req", "ok"])));
|
2017-06-05 03:16:40 +08:00
|
|
|
# mismatched certificate request (rsa)
|
|
|
|
ok(run(test(["x509_check_cert_pkey_test",
|
2021-03-22 21:16:56 +08:00
|
|
|
src_file("x509-check.csr"),
|
|
|
|
src_file("wrongkey.pem"), "req", "failed"])));
|
|
|
|
|
|
|
|
test_PEM_X509_INFO_read("root-cert.pem", "1");
|
2021-03-22 23:23:24 +08:00
|
|
|
test_PEM_X509_INFO_read("root-key.pem", "1");
|
|
|
|
test_PEM_X509_INFO_read("key-pass-12345.pem", "1");
|
2021-03-22 21:16:56 +08:00
|
|
|
test_PEM_X509_INFO_read("cyrillic_crl.utf8", "1");
|