2012-02-23 2 views
1

У нас есть система, использующая универсальный веб-мессенджер Symantec PGP.PHP Чтение S/Mime email p7m attachment (Base64?)

Это означает, что электронные письма отправляются мне с использованием s/mime-шифрования из сертификата pkcs12.

У меня проблемы с чтением сообщений на PHP.

У меня есть код imap, но теперь, как я могу прочитать зашифрованный прикрепленный файл p7m. Это просто закодировано и подписано Base64?

EDIT: У меня есть открытый ключ.

Вот информация мим: -

Content-Type: application/pkcs7-mime; smime-type=enveloped-data;\r\n\tname="Message.p7m"\r\nContent-Transfer-Encoding: BASE64\r\nContent-Disposition: attachment; filename="Message.p7m" 

ответ

1

P7M тип файла в первую очередь ассоциируется с PKCS #7 MIME Message. См Section 3.2 in RFC 2311:

3.2 The application/pkcs7-mime Type 

    The application/pkcs7-mime type is used to carry PKCS #7 objects of 
    several types including envelopedData and signedData. The details of 
    constructing these entities is described in subsequent sections. This 
    section describes the general characteristics of the 
    application/pkcs7-mime type. 

    This MIME type always carries a single PKCS #7 object. The PKCS #7 
    object must always be BER encoding of the ASN.1 syntax describing the 
    object. The contentInfo field of the carried PKCS #7 object always 
    contains a MIME entity that is prepared as described in section 3.1. 
    The contentInfo field must never be empty. 

    Since PKCS #7 objects are binary data, in most cases base-64 transfer 
    encoding is appropriate, in particular when used with SMTP transport. 
    The transfer encoding used depends on the transport through which the 
    object is to be sent, and is not a characteristic of the MIME type. 

    Note that this discussion refers to the transfer encoding of the PKCS 
    \#7 object or "outside" MIME entity. It is completely distinct from, 
    and unrelated to, the transfer encoding of the MIME entity secured by 
    the PKCS #7 object, the "inside" object, which is described in 
    section 3.1. 

    Because there are several types of application/pkcs7-mime objects, a 
    sending agent SHOULD do as much as possible to help a receiving agent 
    know about the contents of the object without forcing the receiving 
    agent to decode the ASN.1 for the object. The MIME headers of all 
    application/pkcs7-mime objects SHOULD include the optional "smime- 
    type" parameter, as described in the following sections. 

Это в основном безопасный файл электронной почты, отправляемой в зашифрованном виде. Если все настроено правильно, у вас должен быть открытый ключ, необходимый для дешифрования файла. Если нет, загрузите его.

В вашем случае кодировка передачи Base64. Сначала декодируйте вложение (если вы этого еще не сделали), а затем обработайте двоичные данные.

+0

У меня есть открытый ключ. Как обрабатывать двоичные декодированные данные? В каком порядке я это делаю? –

+0

Если вы перейдете по ссылке на RFC выше, вы увидите, как она создана. Вам просто нужно обратить вспять процесс. Вы найдете подробное описание там, гораздо лучше, как я мог бы его монета. – hakre

+0

Хорошо, разобрал. Нам не нужно расшифровывать вложение base64. Функции PHP openssl просто выводят дешифрованное сообщение, пока ваш сертификат/ключ настроен правильно. –