
openssl_pkcs12_export 함수를 사용하여 PKCS#12 파일을 생성하는 방법은 다음과 같습니다.
1. 비밀키와 인증서를 포함하려면, 먼저 비밀키와 인증서를 읽어야 합니다. 이때, 비밀키와 인증서를 읽는 방법은 다음과 같습니다.
#hostingforum.kr
php
$privateKey = openssl_pkey_get_private($privateKeyPath);
$cert = openssl_x509_read($certPath);
2. 읽어온 비밀키와 인증서를 openssl_pkcs12_export 함수에 전달하여 PKCS#12 파일을 생성합니다.
#hostingforum.kr
php
openssl_pkcs12_export($privateKey, $cert, $password, $outputPath);
3. 비밀키와 인증서를 포함하는 PKCS#12 파일을 생성하는 예제는 다음과 같습니다.
#hostingforum.kr
php
$privateKeyPath = 'path/to/private/key';
$certPath = 'path/to/cert';
$password = 'password';
$outputPath = 'path/to/output/p12';
$privateKey = openssl_pkey_get_private($privateKeyPath);
$cert = openssl_x509_read($certPath);
openssl_pkcs12_export($privateKey, $cert, $password, $outputPath);
이러한 방법으로 비밀키와 인증서를 포함하는 PKCS#12 파일을 생성할 수 있습니다.
2025-03-03 11:25