Skip to content

Commit

Permalink
Check CMS failure during BIO setup with -stream is handled correctly
Browse files Browse the repository at this point in the history
Test for the issue fixed in the previous commit

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
  • Loading branch information
mattcaswell authored and t8m committed Feb 3, 2023
1 parent 8818064 commit f596ec8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/recipes/80-test_cms.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use warnings;
use POSIX;
use File::Spec::Functions qw/catfile/;
use File::Compare qw/compare_text compare/;
use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file bldtop_dir bldtop_file/;
use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file bldtop_dir bldtop_file with/;

use OpenSSL::Test::Utils;

Expand Down Expand Up @@ -50,7 +50,7 @@ my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib)

$no_rc2 = 1 if disabled("legacy");

plan tests => 14;
plan tests => 15;

ok(run(test(["pkcs7_test"])), "test pkcs7");

Expand Down Expand Up @@ -972,3 +972,14 @@ ok(!run(app(['openssl', 'cms', '-verify',
"SignedInvalidMappingFromanyPolicyTest7.eml")
])),
"issue#19643");

# Check that we get the expected failure return code
with({ exit_checker => sub { return shift == 6; } },
sub {
ok(run(app(['openssl', 'cms', '-encrypt',
'-in', srctop_file("test", "smcont.txt"),
'-stream', '-recip',
srctop_file("test/smime-certs", "badrsa.pem"),
])),
"Check failure during BIO setup with -stream is handled correctly");
});
18 changes: 18 additions & 0 deletions test/smime-certs/badrsa.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN CERTIFICATE-----
MIIDbTCCAlWgAwIBAgIToTV4Z0iuK08vZP20oTh//hC8BDANBgkqhkiG9w0BAQ0FADAtMSswKQYD
VfcDEyJTYW1wbGUgTEFNUFMgQ2VydGlmaWNhdGUgQXV0aG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