60-test_x509_check_cert_pkey.t 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #! /usr/bin/env perl
  2. # Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the OpenSSL license (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use OpenSSL::Test qw/:DEFAULT srctop_file/;
  9. use OpenSSL::Test::Utils;
  10. setup("test_x509_check_cert_pkey");
  11. plan tests => 6;
  12. # rsa
  13. ok(run(test(["x509_check_cert_pkey_test",
  14. srctop_file("test", "certs", "servercert.pem"),
  15. srctop_file("test", "certs", "serverkey.pem"), "cert", "ok"])));
  16. # mismatched rsa
  17. ok(run(test(["x509_check_cert_pkey_test",
  18. srctop_file("test", "certs", "servercert.pem"),
  19. srctop_file("test", "certs", "wrongkey.pem"), "cert", "failed"])));
  20. SKIP: {
  21. skip "DSA disabled", 1, if disabled("dsa");
  22. # dsa
  23. ok(run(test(["x509_check_cert_pkey_test",
  24. srctop_file("test", "certs", "server-dsa-cert.pem"),
  25. srctop_file("test", "certs", "server-dsa-key.pem"), "cert", "ok"])));
  26. }
  27. # ecc
  28. SKIP: {
  29. skip "EC disabled", 1 if disabled("ec");
  30. ok(run(test(["x509_check_cert_pkey_test",
  31. srctop_file("test", "certs", "server-ecdsa-cert.pem"),
  32. srctop_file("test", "certs", "server-ecdsa-key.pem"), "cert", "ok"])));
  33. }
  34. # certificate request (rsa)
  35. ok(run(test(["x509_check_cert_pkey_test",
  36. srctop_file("test", "certs", "x509-check.csr"),
  37. srctop_file("test", "certs", "x509-check-key.pem"), "req", "ok"])));
  38. # mismatched certificate request (rsa)
  39. ok(run(test(["x509_check_cert_pkey_test",
  40. srctop_file("test", "certs", "x509-check.csr"),
  41. srctop_file("test", "certs", "wrongkey.pem"), "req", "failed"])));