인증서 pfx -> cert, key 추출하기

2024. 4. 9. 14:06IT

.pfx 파일 -> .crt

openssl pkcs12 -in WILD.i.co.kr-root-chain.pfx -clcerts -nokeys -out iscreams.crt

.pfx 파일 -> .key

openssl pkcs12 -in WILD.i.co.kr-root-chain.pfx -nocerts -out iscreams.key

error troubleshooting

Error outputting keys and certificates
00F6300F01000000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:373:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()

해당 에러가 발생하였다.
이유: unsupported, Algorithm, RC2-40-CBC
이는 RC2-40-CBC 알고리즘을 지원하지 않는다는 얘기
openssl pkcs12의 옵션을 보면 해당 알고리즘을 사용하도록 -legacy 옵션이 있다.

In the legacy mode, the default algorithm for certificate encryption is RC2_CBC or 3DES_CBC depending on whether the RC2 cipher is enabled in the build. The default algorithm for private key encryption is 3DES_CBC. If the legacy option is not specified, then the legacy provider is not loaded and the default encryption algorithm for both certificates and private keys is AES_256_CBC with PBKDF2 for key derivation.

이는 레거시 모드에서는 인증서 암호화를 위한 기본 알고리즘은 RC2_CBC나 3DES_CBC을 쓴다
그러므로 명령어 중간에 -legacy 옵션을 넣는다.

openssl pkcs12 -in WILD.i.co.kr-root-chain.pfx -clcerts -nokeys -out iscreams.crt
openssl pkcs12 -legacy -in WILD.i.co.kr-root-chain.pfx -nocerts -out iscreams.key

ps ENCRYPTED PRIVATE KEY -> PRIVATE KEY

openssl rsa -in s.key -out decrypted_s.key

참조

링크텍스트
링크텍스트

'IT' 카테고리의 다른 글

Signoz 서비스 expose  (0) 2024.04.09
EKS위에 Signoz 설치 방법  (0) 2024.04.09
[K8S] Node port  (0) 2024.04.09
[AWS] VPC와 Subnet  (0) 2024.04.09
[Monitoring] Signoz  (0) 2024.04.09