1 To suppose certificate chaining in smime_keys, see upstream
2 http://bugs.mutt.org/3339
13 + return undef unless (defined($file) && -e $file);
21 + $in_cert = 1 if ( /^-----BEGIN CERTIFICATE-----$/ );
24 + if ( /^-----END CERTIFICATE-----$/ ) {
34 if(@ARGV == 1 and $ARGV[0] eq "init") {
38 change_label($ARGV[1]);
40 elsif(@ARGV == 2 and $ARGV[0] eq "add_cert") {
41 - my $format = -B $ARGV[1] ? 'DER' : 'PEM';
42 - my $cmd = "$opensslbin x509 -noout -hash -in $ARGV[1] -inform $format";
43 - my $cert_hash = `$cmd`;
44 - $? and die "'$cmd' returned $?";
46 - my $label = query_label;
47 - &add_certificate($ARGV[1], \$cert_hash, 1, $label, '?');
48 + foreach my $cert ( get_certs( $ARGV[1] ) ) {
50 + my $file = sprintf( '/tmp/smime-%d.%d', $$, int(rand( 999999 ) ) );
51 + print STDERR "TMPFILE: $file\n";
53 + die( "ERROR: TMPFILE $file existss?!?!" );
59 + my $format = -B $file ? 'DER' : 'PEM';
60 + my $cmd = "$opensslbin x509 -noout -hash -in $file -inform $format";
62 + my $cert_hash = `$cmd`;
63 + $? and die "'$cmd' returned $?";
65 + my $label = query_label;
66 + &add_certificate($ARGV[1], \$cert_hash, 1, $label, '?');
70 elsif(@ARGV == 2 and $ARGV[0] eq "add_pem") {
71 -e $ARGV[1] and -s $ARGV[1] or die("$ARGV[1] is nonexistent or empty.");
73 print "the key ID. This has to be _one_ word (no whitespaces).\n\n";
75 print "Enter label: ";
76 - chomp($input = <STDIN>);
78 + chomp($input) if ( defined($input) );
80 - my ($label, $junk) = split(/\s/, $input, 2);
81 + my ($label, $junk) = split(/\s/, $input, 2) if ( defined($input) );
84 and print "\nUsing '$label' as label; ignoring '$junk'\n";