<div dir="ltr"><div>Hello gentlemen,</div><div><br></div><div>I am troubleshooting an issue with an AS2 setup, the error I'm getting is AS1_get_obect:header too long:asn1. Playing with another system, I was able to replicate the issue by switching the encoding from Base64 to Binary.</div><div><br></div><div>Before i get a smart response... the trading partner can't switch the encoding from binary to base64,.. so here I am ;-)</div><div><br></div><div>Apparently openssl assumes that all SMIME messages are base64 encoded, and balks when this is not the case?</div><div><br></div><div>Basically the transmission is an encrypted and signed. The decryption goes well, but then the signature verification fails, the full error message is below.</div><div><br></div><div>139666245117592:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:157:<br>139666245117592:error:0D0D106E:asn1 encoding routines:B64_READ_ASN1:decode error:asn_mime.c:192:<br>139666245117592:error:0D0D40CC:asn1 encoding routines:SMIME_read_ASN1:asn1 sig parse error:asn_mime.c:490:<br><br></div><div><div>It looks like I'm not alone in this...</div><div><a href="https://superuser.com/questions/1097544/error-when-decompress-smime-file">https://superuser.com/questions/1097544/error-when-decompress-smime-file</a> </div><div></div></div><div><br></div><div>According to the link above... I should be able to discard the the headers and handle the binary body with openssl. Copying/Pasting from the link above...</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);border-radius:3px;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">$ sed '1,/^\r$/d' <suA97544.mime >suA97544.body
</code></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);border-radius:3px;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">$ openssl cms -uncompress -inform der -in suA97544.body
</code></pre>Now, when I try this suggestion... sed does strip the MIME headers, but still when attempting to uncompress with openssl there is an error.</div><div><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);border-radius:3px;color:rgb(36,39,41)">Error reading S/MIME message
140081090963096:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1217:
140081090963096:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:386:Type=CMS_ContentInfo</pre></div></div><div>I am hoping I am just missing something here... obviously openssl is not my forte. :-)<br></div><div><br></div><div>For illustration purposes, here is the original structure:</div><div><br></div><div><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);border-radius:3px;color:rgb(36,39,41)">content-type: multipart/signed; protocol="application/pkcs7-signature"; micalg=SHA-1;<br>        boundary="_=4094798051677677Sterling4094798051677677MOKO"<br><br>--_=4094798051677677Sterling4094798051677677MOKO<br>content-type: application/pkcs7-mime; smime-type=compressed-data; name=smime.p7m<br>
.... (Binary)<br>--_=4094798051677677Sterling4094798051677677MOKO<br>content-type: application/pkcs7-signature; name=EDIINTSIG.p7s

.... (Binary)</pre></div><div><br></div><div>After sed... the structure looks like this... which fails to uncompress with openssl</div></div><div><br></div><div><div><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);border-radius:3px;color:rgb(36,39,41)">--_=4094798051677677Sterling4094798051677677MOKO<br>content-type: application/pkcs7-mime; smime-type=compressed-data; name=smime.p7m<br>
.... (Binary)
--_=4094798051677677Sterling4094798051677677MOKO<br>content-type: application/pkcs7-signature; name=EDIINTSIG.p7s

... (Binary)

openssl pkcs7 -in 5d7aa60750796.dat.3 -inform DER
</pre></div></div><div><br></div></div><div>Last but not least, if I split the two parts, remove the boundary and content-type line... I can use pkcs7 to convert the binary content for each individual file, and I get this, but I'm not sure that this is what I think it is (the data what the next step would be. Talk about shooting in the dark. LoL.<br><br><div><div><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);border-radius:3px;color:rgb(36,39,41)">openssl pkcs7 -in 5d7aa60750796.dat.3 -inform DER<br>-----BEGIN PKCS7-----<br>MIHOBgsqhkiG9woBCRABCaCBvjCAAgEAMAoGCyqGSIb3CgEJEAMIMIAGCSqGSIb3<br>CgEHAaCAJIAEAnicBIGMc87PK0nNK9EtqSxItVJwLCjIyUxOLMnMz9N3dfHUjTA0<br>4uVKhirJTLFSsPH19/Z3dnMGSeblp6Qa6hqaJRsYGicaJ5oY6hoZWRgZmJuaWTi7<br>uTsGGzlAFNrxcvFyKQOBQoiHZ7ACEDkqhLgGhyj4ugYHO7q7KoDlXPwV/PxDFAKC<br>/J2BwmAxABhSKacAAAAAAAA=<br>-----END PKCS7-----<br></pre></div></div></div></div><div><br></div><div>I suspect this is a compressed version of the actual message, but I can't get any further. Any help, recommendations, thoughts would be greatly appreciated!!</div><div><br></div><div>Is there a solid openssl implementation that can handle the binary encoded smime message?</div><div><br></div><div>Thanks in advance!</div><div><br></div><div>CM.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<div lang="EN-US">
<div class="gmail-m_8197292837817799812x_WordSection1">
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div></div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div></div>