]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/25-test_gen.t
Unified copyright for test recipes
[thirdparty/openssl.git] / test / recipes / 25-test_gen.t
1 #! /usr/bin/env perl
2 # Copyright 2015-2016 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
9
10 use strict;
11 use warnings;
12
13 use File::Spec;
14 use OpenSSL::Test qw/:DEFAULT srctop_file/;
15 use OpenSSL::Test::Utils;
16
17 setup("test_gen");
18
19 plan tests => 1;
20
21 my $T = "testcert";
22 my $KEY = 512;
23 my $CA = srctop_file("certs", "testca.pem");
24
25 unlink "$T.1", "$T.2", "$T.key";
26 open RND, ">>", ".rnd";
27 print RND "string to make the random number generator think it has entropy";
28 close RND;
29
30 subtest "generating certificate requests" => sub {
31 my @req_new;
32 if (disabled("rsa")) {
33 @req_new = ("-newkey", "dsa:".srctop_file("apps", "dsa512.pem"));
34 } else {
35 @req_new = ("-new");
36 note("There should be a 2 sequences of .'s and some +'s.");
37 note("There should not be more that at most 80 per line");
38 }
39
40 unlink "testkey.pem", "testreq.pem";
41
42 plan tests => 2;
43
44 ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
45 @req_new, "-out", "testreq.pem"])),
46 "Generating request");
47
48 ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
49 "-verify", "-in", "testreq.pem", "-noout"])),
50 "Verifying signature on request");
51 };