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