라이브러리
[PHP] openssl_pkcs12_export_to_file - PKCS#12 호환 인증서 저장소 파일을 내보냅니다.
openssl_pkcs12_export_to_file 함수
`openssl_pkcs12_export_to_file` 함수는 PHP에서 PKCS#12 파일을 생성하는 데 사용되는 함수입니다. PKCS#12 파일은 SSL/TLS 인증서와 개인 키를 포함하는 파일로, 웹 서버나 다른 서버에 설치할 때 사용됩니다.
함수의 매개 변수
`openssl_pkcs12_export_to_file` 함수의 매개 변수는 다음과 같습니다.
- `$cert`: 인증서
- `$key`: 개인 키
- `$passphrase`: 암호
- `$filename`: 파일 이름
- `$certinfo`: 인증서 정보 (선택 사항)
- `$dane`: DANE (선택 사항)
함수의 반환 값
`openssl_pkcs12_export_to_file` 함수는 성공 시 `true`를 반환하고, 실패 시 `false`를 반환합니다.
예제
다음은 `openssl_pkcs12_export_to_file` 함수를 사용하는 예제입니다.
#hostingforum.kr
php
<?php
// 인증서와 개인 키를 생성합니다.
$cert = openssl_csr_new('CN=example.com', 'key');
$privateKey = openssl_pkey_get_private('file://key.pem');
$cert = openssl_x509_parse(openssl_x509_read('file://cert.pem'));
// PKCS#12 파일을 생성합니다.
$passphrase = '암호';
$filename = 'example.p12';
if (openssl_pkcs12_export_to_file($cert, $privateKey, $passphrase, $filename)) {
echo "PKCS#12 파일이 성공적으로 생성되었습니다.";
} else {
echo "PKCS#12 파일 생성에 실패했습니다.";
}
?>
참고
- `openssl_csr_new` 함수는 인증서 사양을 생성하는 데 사용됩니다.
- `openssl_pkey_get_private` 함수는 개인 키를 가져오는 데 사용됩니다.
- `openssl_x509_parse` 함수는 인증서 정보를 파싱하는 데 사용됩니다.
- `openssl_x509_read` 함수는 인증서를 읽는 데 사용됩니다.
이 예제는 인증서와 개인 키를 생성하고, PKCS#12 파일을 생성하는 데 사용됩니다. `openssl_pkcs12_export_to_file` 함수는 인증서와 개인 키를 포함하는 PKCS#12 파일을 생성하는 데 사용됩니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.