RFC 2822 section 2.1 requires CR/LF line endings for MIME. There is an (undocumented) option -crlfeol to smime, which does the Right Thing for the headers generated by the ASN1 code (asn_mime.c) by using CR/LF line endings. However, the EOL generated in smime.c for the "To", "From" and "Subject" headers remains as LF.
The attached patch uses CR/LF for consistency on the smime.c generated headers when -crlfeol is supplied.
Index: smime.c =================================================================== RCS file: /v/openssl/cvs/openssl/apps/smime.c,v retrieving revision 1.69 diff -u -w -r1.69 smime.c --- smime.c 5 Nov 2008 18:38:51 -0000 1.69 +++ smime.c 12 Jan 2009 01:51:32 -0000 @@ -113,6 +113,7 @@ const EVP_MD *sign_md = NULL; int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; int keyform = FORMAT_PEM; + const char *mime_eol; #ifndef OPENSSL_NO_ENGINE char *engine=NULL; #endif @@ -774,12 +775,16 @@ PEM_write_bio_PKCS7(out, p7); else { + if (flags & PKCS7_CRLFEOL) + mime_eol = "\r\n"; + else + mime_eol = "\n"; if (to) - BIO_printf(out, "To: %s\n", to); + BIO_printf(out, "To: %s%s", to, mime_eol); if (from) - BIO_printf(out, "From: %s\n", from); + BIO_printf(out, "From: %s%s", from, mime_eol); if (subject) - BIO_printf(out, "Subject: %s\n", subject); + BIO_printf(out, "Subject: %s%s", subject, mime_eol); if (outformat == FORMAT_SMIME) { if (operation == SMIME_RESIGN)
-- Dean