Archived Forum Post

Index of archived forum posts

Question:

email: cilkat can not read p7s attachments

Sep 16 '13 at 10:05

I will receive a eMail with two attachments

a) the textfile
b) the p7s-detached Signaturfile of the textfile

both with the same filname, but the textfile has the ending of .txt, the p7s-detached Signaturfile has the ending of .p7s

Al eMail programms accepted both attachments, but chilkat recognizes only one attachments, the text file.

I can not extract the p7s-detached Signaturfile using chilkat and vbnet 10, because the function email.NumAttachments returns only 1 attachment

Please, show the example:

Content-Type: multipart/mixed;
    boundary=------------000007010604080006050102

This is a multi-part message in MIME format.

--------------000007010604080006050102 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable

--=20 eMail body --------------000007010604080006050102 Content-Type: text/plain; name=7406362956597X.txt Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=7406362956597X.txt

7406362956597X'7406362956597X'

Content-Type: application/x-pkcs7-signature; name=7406362956597X.p7s Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=7406362956597X.p7s

ZNZilN72GYgteDnvSvv7AR3bbm86Pkxv47L4+6pxi7nNESiSb73te+ebs3kgKI2CiBPLOqlYb5t/ +9nzZd2D07EyvxmOyz8mfVkzS4d5o/4/lQGiLwHd1EW0lsnkL2zGwYtlFSndnJthasEnReMGxarS 6+heKRhrbWPFlgf4gfWDa5bjvrZJjaVEMZykr2hvHgrGXJ6yrWYYbiGjPNuIduSyLjD8lAPIjhmH xrOmAnxnYaYn7PXz2OmX3Ec1i17DsrL3caFiTbPl73hcqeKxAgMBAAGjggEJMIIBBTAMBgNVHRMB Af8EAjAAMFYGCWCGSAGG+EIBDQRJFkdUbyBnZXQgeW91ciBvd24gY2VydGlmaWNhdGUgZm9yIEZS RUUgaGVhZCBvdmVyIHRvIGh0dHA6Ly93d3cuQ0FjZXJ0Lm9yZzBABgNVHSUEOTA3BggrBgEFBQcD BAYIKwYBBQUHAwIGCisGAQQBgjcKAwQGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAyBggrBgEFBQcB AQQm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GNWJU+vfIGw5Ba rLVg9plDAaOIcJydYp2kh69nWA0wNjvmrUjTy3QChnE+4isDaPE0YkBGO1PqKPSs+2aVU4pNXf07 2WDXynlpO7FlkqbGgYJcnM3rTQGKpd8RVaoVyh83wIKYcGHbanyWo44uVD5PIamQ79yCv9zoRa1N kHMIPJRlsASZdn/ivMJqFaqXBDck2B6UTm0OUb7WxI/Klm33Q9/oMGUnO3u7Q0NjxEP3suxozOEZ jiL7mOF7Wj4BNzuLCLCi85VOGsubzZqx27Jw8C1K29iw429FSDMS//48MipU98T3ivCII8JH/mR6 bBNcQ0EMTrozGzFHlRzSmVY9AorVY89OHSTGaa3V

--------------000007010604080006050102--


Answer

Perhaps it is caused by this: http://www.chilkatsoft.com/faq/AttachedMsgsNumAttach.html

or this: http://www.cknotes.com/?p=280


Answer

When an email object loads MIME via the LoadEml method, or by calling SetFromMimeText, or when it is loaded internally by the MailMan/IMAP objects when receiving email from a server, the MIME is decomposed and stored in an internal email object model. Because the MIME is decomposed, it is at this point that all signatures (if present) must be verified because the MIME will no be longer available in its original form. Therefore, it is not possible to unwrap the PKCS7 security layers at a later time. The results of signature verification and/or decryption are available in the email object properties: ReceivedSigned, ReceivedEncrypted, SignaturesValid, Decrypted, and by methods: GetSignedByCert, GetEncryptedByCert, etc.Note: This only applies to the Chilkat.Email object, not the Chilkat.Mime object.


Answer

Thanks for the answer.

I load the eMail from a POP3-Server. The email has two attachments and, additionally, is encrypt and S/MIME-signed.

After the load of the eMail from the POP3-Server I decrypt and save the eMail to a .eml File. Do work with the S/MIME Signatur are not a problem. I get all relevant function like GetSignedByCert, ReceivedSigned, SignaturesValid a.s.o.

The saved eml-File contains the two attachment: Content-Disposition: attachment; filename=7406362956597X.txt Content-Type: application/x-pkcs7-signature; name=7406362956597X.p7s

But, I can not extract and save all two attachment, only the 7406362956597X.txt The Chilkat-email object returns only a number of 1 attachment.


Answer

I modified the internal logic so that application/x-pkcs7-signature content-types are recognized as attachments if the content-disposition header explicitly specifies "attachment", as it does in your email.

Here is a new 32-bit .NET 4 assembly:
http://www.chilkatsoft.com/preRelease/ChilkatDotNet4.zip

(Pre-releases are now v9.4.0. The anticipated release date of this new version is sometime in mid-December 2012.)


Answer

many thanks to you


Answer

Hello, i have the same Issue, my eml contains a p7s:

To: xxxxxx@pec.it
From: posta-certificata@pec.aruba.it
X-Ricevuta: accettazione
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="----BDCB2FAF6A3A2BF856B80AAFEB7842AF"

This is an S/MIME signed message

------BDCB2FAF6A3A2BF856B80AAFEB7842AF
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1379152536-31118-7"

This is a multi-part message in MIME format...

------------=_1379152536-31118-7
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

-- Ricevuta di accettazione del messaggio indirizzato a xxxxxx@nttdat=
a.com ("posta ordinaria") --

Il giorno 14/09/2013 alle ore 11:55:36 (+0200) il messaggio con Oggetto
"I: CONSEGNA: SCUOLE-FORM\SCUOLE-FORM-10/04/2013-0001993 -  Trasmissione#18=
5842#" inviato da "xxxxxx@pec.it"
ed indirizzato a:
xxxxxx@nttdata.com ("posta ordinaria")
=E8 stato accettato dal sistema di Posta Certificata.
Identificativo del messaggio: opec271.20130914115536.31118.04.1.15@pec.arub=
a.it
L'allegato daticert.xml contiene informazioni di servizio sulla trasmissione

------------=_1379152536-31118-7
Content-Type: application/xml; name="daticert.xml"
Content-Disposition: inline; filename="daticert.xml"
Content-Transfer-Encoding: base64

PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHBvc3Rh
.....
PgogICAgPC9kYXRpPgo8L3Bvc3RhY2VydD4K

------------=_1379152536-31118-7--

------BDCB2FAF6A3A2BF856B80AAFEB7842AF
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"

MIIJqwYJKoZIhvcNAQcCoIIJnDCCCZgCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3
.....
iAh5056ApccizKhiOoTjvtRYgV1GrkqguW9dDfYKJQ==

------BDCB2FAF6A3A2BF856B80AAFEB7842AF--

My version IS mail.Version "9.4.1.42"

I need to get the p7s file in my eml when i save it to disk, it's needed as proof (italian legal stuff), but when i load ans save the email with with this code, i loose the p7s part of the message

    MailMan mm = new MailMan();
    mm.UnlockComponent(ChilkatKeys.Mail);
    Email mail = mm.LoadEml(@"C:\work\provaCK\ACC\ACC.eml");
    mail.SaveEml("out.eml");

in mail, i do not have anymore the p7s, as it passes automatically the UnwrapSecurity call.. I would need that saveeml, saves the RAW email, as it's received with the p7s, a saveeml2, or a SaveRawEml would also be ok, as i need the mail exacly as it comes from my provider that serves the email trough imap/s and/or pop/s Thanks