Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
Customer is trying to decrypt the mailfile and write another file with decrypted email data. but getting empty file. below command giving me below error, what could be the possible reasons. this seems to have happened after customer updated there certificate before that same command seemed to be working fine.

#command my $system_output = system("$OPENSSL smime -decrypt -in $mailfile -rec +ip $RECIP_CERT -inkey $RECIP_KEY -passin pass:$RECIP_PASSWORD > ${ma +ilfile}.txt"); &DebugIncoming("SYSTEM OUTPUT : $system_output"); &DebugIncoming("FILE SIZE :". -s ${mailfile}.txt); ##it returning empt +y file.

#Error in detail
Error reading S/MIME message
2992:error:0D0D40CD:asn1 encoding routines:SMIME_read_ASN1:invalid mime type:crypto/asn1/asn_mime.c:460:type: multipart/alternative
Thank you.

Replies are listed 'Best First'.
Re: Error reading S/MIME message with openssl
by Corion (Pope) on Oct 05, 2019 at 09:37 UTC

    Does the error occur without using Perl as well?

    What is the output if you run the following command on the shell (with the variables replaced by the values in your Perl program):

    $OPENSSL smime -decrypt -in $mailfile -recip $RECIP_CERT -inkey $RECIP +_KEY -passin pass:$RECIP_PASSWORD

    If you get the same output there, the problem is with $OPENSSL or with the client input and has nothing to do with Perl.

Re: Error reading S/MIME message with openssl
by jcb (Curate) on Oct 05, 2019 at 19:43 UTC

    What has changed in the certificate? Does the new certificate specify different algorithms, perhaps implicitly?

    That is an OpenSSL error, complaining either that it does not like multipart/alternative or that the MIME type crypto/asn1 is not recognized. Perhaps you need a newer version of OpenSSL?