2012-02-23 6 views
1

시만텍 PGP Universal Web Messenger를 사용하는 시스템이 있습니다.PHP S/MIME 전자 메일 p7m 첨부 파일 읽기 (Base64?)

이것은 pkcs12 인증서의 s/mime 암호화를 사용하여 전자 메일이 나에게 전송되었음을 의미합니다.

PHP에서 메시지를 읽는 데 문제가 있습니다.

나는 모든 imap 코드를 가지고 있지만 암호화 된 p7m 첨부 파일은 어떻게 읽습니까? Base64로 인코딩되고 서명 되었습니까?

편집 : 공개 키를 가지고 있습니다. 여기

는 마임 정보입니다 : -

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 함수는 cert/key가 모두 올바르게 설정되어있는 한 해독 된 메시지를 출력합니다. –