2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
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
13 use OpenSSL::Test::Utils;
14 use OpenSSL::Test qw/:DEFAULT srctop_file/;
20 require_ok(srctop_file('test','recipes','tconversion.pl'));
22 open RND, ">>", ".rnd";
23 print RND "string to make the random number generator think it has randomness";
26 # Check for duplicate -addext parameters
27 my $val = "subjectAltName=DNS:example.com";
28 my $val2 = " " . $val;
31 ok(!run(app(["openssl", "req", "-new", "-addext", $val, "-addext", $val])));
32 ok(!run(app(["openssl", "req", "-new", "-addext", $val, "-addext", $val2])));
33 ok(!run(app(["openssl", "req", "-new", "-addext", $val, "-addext", $val3])));
34 ok(!run(app(["openssl", "req", "-new", "-addext", $val2, "-addext", $val3])));
36 subtest "generating certificate requests" => sub {
38 if (disabled("rsa")) {
39 @req_new = ("-newkey", "dsa:".srctop_file("apps", "dsa512.pem"));
42 note("There should be a 2 sequences of .'s and some +'s.");
43 note("There should not be more that at most 80 per line");
48 ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
49 @req_new, "-out", "testreq.pem"])),
50 "Generating request");
52 ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
53 "-verify", "-in", "testreq.pem", "-noout"])),
54 "Verifying signature on request");
57 my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf"));
59 run_conversion('req conversions',
61 run_conversion('req conversions -- testreq2',
62 srctop_file("test", "testreq2.pem"));
64 unlink "testkey.pem", "testreq.pem";
70 subtest $title => sub {
71 run(app(["openssl", @openssl_args,
72 "-in", $reqfile, "-inform", "p",
74 stderr => "req-check.err", stdout => undef));
75 open DATA, "req-check.err";
77 plan skip_all => "skipping req conversion test for $reqfile"
78 if grep /Unknown Public Key/, map { s/\R//; } <DATA>;
80 tconversion("req", $reqfile, @openssl_args);
83 unlink "req-check.err";