인증서가 필요한 이유
웹 사이트 이용자가 웹 사이트를 안전하게 이용할 수 있도록 하기 위해 인증서가 필요함
웹 사이트에 인증서를 적용하면 안전해지는 이유
웹 브라우저가 서버에게 데이터를 전달할 때 데이터를 암호화 해서 주고, 서버에서도 데이터를 암호화 해서 웹 브라우저에 주기 때문에 중간에서 데이터를 탈취하려는 자로부터 데이터를 보호할 수 있음
인증서 파일 구성 방식
cert.pem: 서버 인증서
chain.pem: 웹 브라우저가 서버 인증서의 유효성을 검사하기 위해 필요한 추가 중간 인증서 또는 인증서들.
fullchain.pem: 서버 인증서(일명 리프 인증서 또는 엔드 엔티티 인증서)를 포함한 모든 인증서. 서버 인증서는 이 파일에서 첫 번째 인증서이며 그 뒤에 모든 중간 인증서가 있습니다. cert.pem + chain.pem
privkey.pem: 인증서의 비공개 키.
적용 방법
Synology DSM 7
개인키: privkey.pem
인증서: cert.pem
중간 인증서: chain.pem
파일 선택 후 확인
Tomcat
.pem
Tomcat Native 사용중일때만 pem 확장자 인증서 사용 가능
PKCS#12 (.p12 또는 .pfx)
webgori@localhost:/home/webgori# ll
total 20
drwxr-xr-x+ 1 root root 94 Feb 10 12:01 .
drwxr-xr-x+ 1 root root 50 Feb 10 12:01 ..
lrwxrwxrwx+ 1 root root 33 Feb 10 12:01 cert.pem -> ../../archive/lolien.kr/cert1.pem
lrwxrwxrwx+ 1 root root 34 Feb 10 12:01 chain.pem -> ../../archive/lolien.kr/chain1.pem
lrwxrwxrwx+ 1 root root 38 Feb 10 12:01 fullchain.pem -> ../../archive/lolien.kr/fullchain1.pem
lrwxrwxrwx+ 1 root root 36 Feb 10 12:01 privkey.pem -> ../../archive/lolien.kr/privkey1.pem
-rwxr-xr-x+ 1 root root 692 Feb 10 12:01 README
webgori@localhost:/home/webgori# openssl pkcs12 -export -in cert.pem -inkey privkey.pem -out cert.p12
Enter Export Password:
Verifying - Enter Export Password:
pem을 p12 또는 pfx로 변환 후 사용 가능
.jks (Java Key Store)
pem을 p12 또는 pfx로 변환
webgori@localhost:/home/webgori# ll
total 24
drwxr-xr-x+ 1 root root 110 Jul 3 14:54 .
drwxr-xr-x+ 1 root root 50 Feb 10 12:01 ..
-rwxr-xr-x+ 1 root root 1638 Jul 3 14:54 cert.p12
lrwxrwxrwx+ 1 root root 33 Feb 10 12:01 cert.pem -> ../../archive/lolien.kr/cert1.pem
lrwxrwxrwx+ 1 root root 34 Feb 10 12:01 chain.pem -> ../../archive/lolien.kr/chain1.pem
lrwxrwxrwx+ 1 root root 38 Feb 10 12:01 fullchain.pem -> ../../archive/lolien.kr/fullchain1.pem
lrwxrwxrwx+ 1 root root 36 Feb 10 12:01 privkey.pem -> ../../archive/lolien.kr/privkey1.pem
-rwxr-xr-x+ 1 root root 692 Feb 10 12:01 README
webgori@localhost:/home/webgori# ./keytool -importkeystore -srckeystore cert.p12 -srcstoretype PKCS12 -destkeystore cert.jks
Importing keystore cert.p12 to cert.jks...
Enter destination keystore password:
Re-enter new password:
Enter source keystore password:
Entry for alias 1 successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
webgori@localhost:/home/webgori# ll
total 568
drwxr-xr-x+ 1 1000 1000 362 Jul 3 17:04 .
drwxr-xr-x+ 1 1000 1000 120 Mar 11 16:32 ..
-rwxr-xr-x+ 1 root root 1851 Jul 3 17:04 cert.jks
-rwxr-xr-x+ 1 root root 1638 Jul 3 17:03 cert.p12
lrwxrwxrwx+ 1 root root 34 Feb 10 12:01 chain.pem -> ../../archive/lolien.kr/chain1.pem
lrwxrwxrwx+ 1 root root 38 Feb 10 12:01 fullchain.pem -> ../../archive/lolien.kr/fullchain1.pem
lrwxrwxrwx+ 1 root root 36 Feb 10 12:01 privkey.pem -> ../../archive/lolien.kr/privkey1.pem
-rwxr-xr-x+ 1 root root 692 Feb 10 12:01 README
p12 또는 pfx를 jks로 변환