How to handle a p7s file in php

354 Views Asked by At

in my infrastructure i am using an email gateway, which is responsible to sign and encrypt outgoing mails and decrypt incoming mails.

if i configure an imap account with my favorite email client and receive messages i can read all messages and see all attachments (Each email contains a single .zip file) without the need to place any kind of certificate. For me the Gateway works fine so far.

But the emails should be handeled by an php script. the retrieval of emails via php works fine. I am only interested in the the attachments of these emails. But instead of the expected .zip files i get single smime.p7s file for each email. The mime-type is marked as octed-stream.

but if i have a closer look into these files it seems to be some kind of binary structure, which contains signature related content and also something thats look like the .zip file (base64 encoded) i want to handle. I am not sure how to handle this file correctly.

Do i have to decrypt it with my certificate and my private key or can i open it with the public cert from the sender? Or do i have do decode it before into base64?

I would be very thankfull for any helpful hint. I read a lot, but i dont get any idea how to handle smime.p7s files correctly or which things i a have to in which order :)

Thanks a lot

Nico

Something binary ...... and many crazy signs .....
and at some point =============> Content-Type: application/x-zip-compressed;
    name="=?iso-8859-1?B?ZWRpVGZ6WnVvcmRudW5nXzE5MDAxMDAzNzAwMDdfMTkwMDEw?=
    =?iso-8859-1?B?MDMwMDEwM18yMDIwMTAwMV8xNjAxNTA2NzQ4MDEyNDk4MDE5?=
    =?iso-8859-1?B?ODQuemlw?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename="=?iso-8859-1?B?ZWRpVGZ6WnVvcmRudW5nXzE5MDAxMDAzNzAwMDdfMTkwMDEw?=
    =?iso-8859-1?B?MDMwMDEwM18yMDIwMTAwMV8xNjAxNTA2NzQ4MDEyNDk4MDE5?=
    =?iso-8859-1?B?ODQuemlw?="

UEsDBBQAAAgIAGcHQVE1IrKnGhMAAClnAgBOABEAZWRpVGZ6WnVvcmRudW5nXzE5MDAxMDAzNzAw .....

0

There are 0 best solutions below