2012-02-23 13 views
1

シマンテックのPGP Universal Web Messengerを使用したシステムがあります。PHP S/MIMEメールを読むp7m添付ファイル(Base64?)

これは、pkcs12証明書からs/mime暗号化を使用して電子メールが私に送信されることを意味します。

PHPでメッセージを読むのに少し問題があります。

私はすべてのimapコードを持っていますが、今はどのように暗号化されたp7m添付ファイルを読むのですか? Base64でエンコードされ、署名されていますか?

編集:私は公開鍵を持っています。 P7Mファイルの種類は主にPKCS #7 MIME Messageに関連付けられている

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

- :ここで

は、MIME情報です。 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. 

これは基本的に暗号化された形式で送信され、安全なEメールファイルです。すべてが正しく設定されている場合は、ファイルを復号化するのに必要な公開鍵が必要です。そうでない場合は、ダウンロードしてください。

あなたの場合、転送エンコーディングはBase64です。最初に添付ファイルをデコードし(まだこれを行っていない場合)、バイナリデータを処理します。

+0

私は公開鍵を持っています。バイナリでデコードされたデータをどのように処理するのですか?どのような順序でこれらを行うのですか? –

+0

上記のRFCへのリンクをたどると、それがどのように作成されたかを見ることができます。プロセスを元に戻す必要があります。私はそれをコインにすることができるので、そこに詳細な説明があります。 – hakre

+0

さて、ソートしました。 base64添付ファイルをデコードする必要はありません。あなたのcert/keyがすべて正しく設定されている限り、PHP openssl関数は解読されたメッセージを出力します。 –

関連する問題