]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/25-test_eai_data.t
Raise an error on syscall failure in tls_retry_write_records
[thirdparty/openssl.git] / test / recipes / 25-test_eai_data.t
CommitLineData
8a302080 1#! /usr/bin/env perl
3c2bdd7d 2# Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
8a302080
DB
3#
4# Licensed under the Apache License 2.0 (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
10use strict;
11use warnings;
12
13use File::Spec;
14use OpenSSL::Test::Utils;
59f4a51a 15use OpenSSL::Test qw/:DEFAULT srctop_file with/;
8a302080
DB
16
17setup("test_eai_data");
18
19#./util/wrap.pl apps/openssl verify -nameopt utf8 -no_check_time -CAfile test/recipes/25-test_eai_data/ascii_chain.pem test/recipes/25-test_eai_data/ascii_leaf.pem
20#./util/wrap.pl apps/openssl verify -nameopt utf8 -no_check_time -CAfile test/recipes/25-test_eai_data/utf8_chain.pem test/recipes/25-test_eai_data/utf8_leaf.pem
21#./util/wrap.pl apps/openssl verify -nameopt utf8 -no_check_time -CAfile test/recipes/25-test_eai_data/utf8_chain.pem test/recipes/25-test_eai_data/ascii_leaf.pem
22#./util/wrap.pl apps/openssl verify -nameopt utf8 -no_check_time -CAfile test/recipes/25-test_eai_data/ascii_chain.pem test/recipes/25-test_eai_data/utf8_leaf.pem
23
59f4a51a 24plan tests => 12;
8a302080
DB
25
26require_ok(srctop_file('test','recipes','tconversion.pl'));
27my $folder = "test/recipes/25-test_eai_data";
28
29my $ascii_pem = srctop_file($folder, "ascii_leaf.pem");
30my $utf8_pem = srctop_file($folder, "utf8_leaf.pem");
31
32my $ascii_chain_pem = srctop_file($folder, "ascii_chain.pem");
33my $utf8_chain_pem = srctop_file($folder, "utf8_chain.pem");
34
53eecb5d
RL
35my $out;
36my $outcnt = 0;
37sub outname {
38 $outcnt++;
39 return "sanout-$outcnt.tmp";
40}
41
42$out = outname();
8a302080
DB
43ok(run(app(["openssl", "x509", "-ext", "subjectAltName", "-in", $ascii_pem, "-noout", "-out", $out])));
44is(cmp_text($out, srctop_file($folder, "san.ascii")), 0, 'Comparing othername for ASCII domain');
45
53eecb5d 46$out = outname();
8a302080
DB
47ok(run(app(["openssl", "x509", "-ext", "subjectAltName", "-in", $utf8_pem, "-noout", "-out", $out])));
48is(cmp_text($out, srctop_file($folder, "san.utf8")), 0, 'Comparing othername for IDN domain');
49
53d0d01f
MC
50SKIP: {
51 skip "Unicode tests disabled on MingW", 2 if $^O =~ /^msys$/;
52
53 ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-verify_email", "学生\@elementary.school.example.com", "-CAfile", $ascii_chain_pem, $ascii_pem])));
54 ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-verify_email", "医生\@大学.example.com", "-CAfile", $utf8_chain_pem, $utf8_pem])));
55}
8a302080
DB
56
57ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $ascii_chain_pem, $ascii_pem])));
58ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $utf8_chain_pem, $utf8_pem])));
59
60ok(!run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $ascii_chain_pem, $utf8_pem])));
61ok(!run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $utf8_chain_pem, $ascii_pem])));
62
59f4a51a
MC
63#Check that we get the expected failure return code
64with({ exit_checker => sub { return shift == 2; } },
65 sub {
66 ok(run(app(["openssl", "verify", "-CAfile",
67 srctop_file("test", "certs", "bad-othername-namec.pem"),
68 "-partial_chain", "-no_check_time", "-verify_email",
69 'foo@example.com',
70 srctop_file("test", "certs", "bad-othername-namec.pem")])));
71 });
72