Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • e500dec
  • /
  • test
  • /
  • recipes
  • /
  • 60-test_x509_check_cert_pkey.t
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:6e7112b4cf3e385f9208f02a45bdceec03d520d5
directory badge Iframe embedding
swh:1:dir:a9c51b2d531fb77c19e21b14c38dd51e828672a1
60-test_x509_check_cert_pkey.t
#! /usr/bin/env perl
# Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License").  You may not use
# 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/;
use OpenSSL::Test::Utils;

setup("test_x509_check_cert_pkey");

plan tests => 11;

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");
}

# rsa
ok(run(test(["x509_check_cert_pkey_test",
             src_file("servercert.pem"),
             src_file("serverkey.pem"), "cert", "ok"])));
# mismatched rsa
ok(run(test(["x509_check_cert_pkey_test",
             src_file("servercert.pem"),
             src_file("wrongkey.pem"), "cert", "failed"])));
SKIP: {
    skip "DSA disabled", 1, if disabled("dsa");
    # dsa
    ok(run(test(["x509_check_cert_pkey_test",
                 src_file("server-dsa-cert.pem"),
                 src_file("server-dsa-key.pem"), "cert", "ok"])));
}
# ecc
SKIP: {
    skip "EC disabled", 2 if disabled("ec");
    ok(run(test(["x509_check_cert_pkey_test",
                 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");

}
# certificate request (rsa)
ok(run(test(["x509_check_cert_pkey_test",
             src_file("x509-check.csr"),
             src_file("x509-check-key.pem"), "req", "ok"])));
# mismatched certificate request (rsa)
ok(run(test(["x509_check_cert_pkey_test",
             src_file("x509-check.csr"),
             src_file("wrongkey.pem"), "req", "failed"])));

test_PEM_X509_INFO_read("root-cert.pem", "1");
test_PEM_X509_INFO_read("root-key.pem", "1");
test_PEM_X509_INFO_read("key-pass-12345.pem", "1");
test_PEM_X509_INFO_read("cyrillic_crl.utf8", "1");

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top