openssl_pkcs7_decrypt
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
openssl_pkcs7_decrypt - S/MIME 암호화된 메시지를 해독합니다.
설명
openssl_pkcs7_decrypt( string $input_filename, string $output_filename, OpenSSLCertificate|string $certificate, OpenSSLAsymmetricKey|OpenSSLCertificate|array|string|null $private_key = null ): bool
certificate
및 private_key
로 지정된 관련 개인 키를 사용하여 input_filename
으로 지정된 파일에 포함된 S/MIME 암호화된 메시지를 해독합니다.
매개변수
input_filename
output_filename
- 해독된 메시지는
output_filename
으로 지정된 파일에 기록됩니다. certificate
private_key
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | private_key 는 이제 OpenSSLAsymmetricKey 또는 OpenSSLCertificate 인스턴스를 허용합니다. 이전에는 OpenSSL key 또는 OpenSSL X.509 CSR 유형의 리소스가 허용되었습니다. |
Examples
예제 #1 openssl_pkcs7_decrypt() 예제
<?php
// $cert and $key are assumed to contain your personal certificate and private
// key pair, and that you are the recipient of an S/MIME message
$infilename = "encrypted.msg"; // this file holds your encrypted message
$outfilename = "decrypted.msg"; // make sure you can write to this file
if (openssl_pkcs7_decrypt($infilename, $outfilename, $cert, $key)) {
echo "decrypted!";
} else {
echo "failed to decrypt!";
}
?>