Hello, I don't understand something..
I have a html mail (only html): Date:... From:....... To............ MIME-Version: 1.0 Content-type: text/html; Charset="ISO-8859-1" <html> [..] </html> I don't know if I've the good method, but I do this in my C program: -> read the message -> put headers into memory (when I found the first \n or the first Content- -> put in a file "the mail", so in the the file I've: Content-Type: text/html; Charset="ISO-8859-1" <html> [...] </html> At this time I've Char *headers= 'From..to...date' Char readfile="/path/to/message_without_headers.msg"; Char writefile="/path/to/message_with_smime.msg"; X509 *cert; EVP_PKEY *key; BIO *in; BIO *mem_buf; PKCS7 *p7=NULL; char signer[1024]="/path/to/cert.pem"; char inkey[1024]='/path/to/key.pem'; int flags = PKCS7_STREAM|PKCS7_DETACHED|PKCS7_BINARY ; ERR_load_crypto_strings(); OpenSSL_add_all_algorithms (); in = BIO_new_file (readfile, "r"); if (!in) die ("BIO_new_fp"); mem_buf = BIO_new (BIO_s_mem()); if (!mem_buf) die ("BIO_new"); key = load_key (inkey,password)); cert = load_cert (signer); p7 = PKCS7_sign (cert, key, NULL, in, flags); if (!p7) die ("PKCS7_sign"); BIO *out = BIO_new_file(writefile, "w"); if (!out) exit(1); int ret = SMIME_write_PKCS7(out, p7, in, flags); if (!ret) exit(1); BIO_free(in); BIO_free(mem_buf); PKCS7_free(p7); now I rewrite the mail -> create a new file -> put headers (original headers) -> put writefile (who contain mail and s/mime) -> put end of boundary If I look this last file, I've: From:....... [....] MIME-VERSION: 1.0 Content-Type: multipart/signed; protocol="application/x[..]"; micalg=sha1; boundary="--boundary" \n This is an S/MIME signed message \n --boundary Content-Type: text/html;\r\n Charset="ISO-8859-1"\r\n \r\n <html>\r\n [...] </html>\r\n \n --boundary\n Content-Type: application/x-pkcs7..............\n [...] \n --boundary--\n 1- why, he don't put the end of the boundary? I must search it into signed message, and put it after 2- the next problem is very strange for me.. If I sent the mail to a gmail address, s/mime is ok. If I open the source of the mail, I see this: Content-Type: multipart/signed;\n Boundary=........\n Protocol=...........\n Micalg=sha1\n \n This is a ..........\n \n --boundary\n Content-Transfer-Encoding: 8bit\n Content-Type: text/html;\n Charset="ISO-8859-1"\n \n <html>\n [.......] If I sent the mail to my mail server (telnet ip_server 25...) I've exactly the mail who i create ->gmail: S/MIME OK -> my server: S/MIME BAD ->gmail: rewrite Content-Type: multipart/signed; protocol= (see he change the order, and put \n) -> my server: nothing to change ->gmail: Add after boundary Content-Transfer-Encoding: 8bit\n -> my server: the same, except I must remove into my program the \r after Content-Type: text/html; ->gmail: remove all \r!! ->my server: the same Why?? I don't understand what the matter, why google rewrite \r\n to \n, and he work fine! thanks ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org