목차
개인키 생성
genrsa -out private.key 1024
비밀번호 제거
openssl rsa -in key.pem.orig -out key.pem
개인키로 파일 암복호화
openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out file.ssl;
openssl rsautl -decrypt -inkey private.pem -in file.ssl -out decrypted.txt
공개키 생성
openssl rsa -in private.key -out public.key -pubout -outform derwriting
PEM포맷으로 생성
openssl rsa -in private.key -out public.key -pubout
인증서
인증서 생성
private.key로 만든 인증서
일반적으로 윈도우에서 .crt파일로 생성하고 리눅스등에서 .pem으로 생성하기도 한다.
openssl req -new -x509 -days 365 -key private.key -out cert.crt -config C:\openssl\ssl\openssl.cnf
국가코드: KR
인증서의 내용
인증서는 pem포맷으로 윈도우의 경우 crt확장자를 인증서로 인식한다. 더블클릭하면 발급대상과 발급자가 있으며, 자세히를 보면 버전, 서명 알고리즘, 유효기간, 주체, 공개키 등이 있다.
웹서버용 인증서
pfx
인증서와 개인키로 생성
crt(pem포맷의 인증서)와 key(pem포맷의 개인키)로부터 생성
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
인증서로 생성
cer 인증서 생성
openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes
개인키 추출
$ openssl.exe pkcs12 -in my.pfx -nocerts -nodes -out private.key