Skip to content

Commit 80d4d29

Browse files
committed
bulk.pl daemon crashes if it failed to load private key (sympa-community#1110)
There is also a case with public key.
1 parent 3a644d4 commit 80d4d29

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/lib/Sympa/Message.pm

+15-3
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,11 @@ sub smime_encrypt {
962962
# encrypt the incoming message parse it.
963963
my $smime = Crypt::SMIME->new();
964964
#FIXME: Add intermediate CA certificates if any.
965-
$smime->setPublicKey($cert);
965+
unless (eval { $smime->setPublicKey($cert) }) {
966+
$log->syslog('err', 'Unable to S/MIME encrypt message: %s',
967+
$EVAL_ERROR);
968+
return undef;
969+
}
966970

967971
# don't; cf RFC2633 3.1. netscape 4.7 at least can't parse encrypted
968972
# stuff that contains a whole header again... since MIME::Tools has
@@ -1055,9 +1059,17 @@ sub smime_sign {
10551059
my $smime = Crypt::SMIME->new();
10561060
#FIXME: Add intermediate CA certificates if any.
10571061
if (length $key_passwd) {
1058-
$smime->setPrivateKey($key, $cert, $key_passwd);
1062+
unless (eval { $smime->setPrivateKey($key, $cert, $key_passwd) }) {
1063+
$log->syslog('err', 'Unable to S/MIME sign message: %s',
1064+
$EVAL_ERROR);
1065+
return undef;
1066+
}
10591067
} else {
1060-
$smime->setPrivateKey($key, $cert);
1068+
unless (eval { $smime->setPrivateKey($key, $cert) }) {
1069+
$log->syslog('err', 'Unable to S/MIME sign message: %s',
1070+
$EVAL_ERROR);
1071+
return undef;
1072+
}
10611073
}
10621074
my $msg_string = eval {
10631075
$smime->sign($dup_head->as_string . "\n" . $self->body_as_string);

0 commit comments

Comments
 (0)