카테고리 보관물: SERVER

톰캣 SSL 적용

1. 키파일 생성
keytool -genkey -keyalg RSA -sigalg SHA1withRSA -alias hanbiro -keysize 2048 -keystore hanbiro.key
※ 참고사항(위의 빨간색 부분과 매칭되게
hanbiro는 키의 alias 이름으로 임의로 작성합니다.
hanbiro.key는 keystore이름으로 임의로 만듭니다
Enter keystore password: (비밀번호를 입력하세요.)
What is your first and last name?
[Unknown]: www.hanbiro.com (인증서 사용을 원하는 도메인)
What is the name of your organizational unit?
[Unknown]: LINUX (부서명)
What is the name of your organization?
[Unknown]: HANBIRO (업체명)
What is the name of your City or Locality?
[Unknown]: SEOCHO (지역명)
What is the name of your State or Province?
[Unknown]: SEOUL(시/도)
What is the two-letter country code for this unit?
[Unknown]: KR
Is CN=www.hanbiro.com, OU=LINUX, O=HANBIRO, L=SEOCHO, ST=SEOUL, C=KR correct?
[no]: y
Enter key password for <hanbiro>
(RETURN if same as keystore password): (엔터를 입력)
키파일이 제대로 생성되었는지 확인해 봅니다.
keytool -list -keystore hanbiro.key
2. CSR 생성
keytool -certreq -alias hanbiro -keyalg RSA -sigalg SHA1withRSA -file hanbiro.csr -keystore hanbiro.key
Enter keystore password: (키파일 생성시에 입력하였던 패스워드를 입력합니다.)
3. 생성된 CSR 예
한비로(www.comodossl.co.kr) 에서 인증서 신청하실 때 위에서 생성하신 CSR 내용을 복사해서 붙여 넣은후 나머지 설치 절차를 거칩니다.
생성된 CSR 을 출력하면 아래와 같은 base64 형식의 문서를 볼 수 있습니다.
[root@ns root]# cat hanbiro.csr
—–BEGIN NEW CERTIFICATE REQUEST—–
MIIBsDCCARkCAQAwcDELMAkGA1UEBhMCS1IxDjAMBgNVBAgTBVN
lb3VsMQ8wDQYDVQQHEwZTZW9j
aG8xEDAOBgNVBAoTB0hhbmJpcm8xDjAMBgNVBAsTBUxpbnV4MR4w
HAYDVQQDExV3d3cucHJvZGln
AAGgADANBgkqhkiG9w0BAQQFAAOBgQBhV3jIaT2wEOB1/AIOedu+4
gECrr+6UIYhwPtSmIeoWXg5
76+UHe5I1M2M/ew5j6d8pq4IBXaTesSrmwZuuuA2Stx4uXjb/Akjr8UIDX
isnycJGmk5dQDCCT3G
8IBd8gwgvQOiAhnfGSjIbStsPOiVCgB60uSz9Jc8s9rPIxh69w==
—–END NEW CERTIFICATE REQUEST—–
—–BEGIN … 부터 마지막 줄 —–END … 까지 복사하여 지정된 SSL 접수페이지에 복사하여 붙여 넣은 뒤 입력정보와 함께 전송하면 접수가 완료됩니다.
4. 인증서 설치
keytool -import -trustcacerts -alias COMODOSSL -file
COMODOSSLCA.crt -keystore hanbiro.key
keytool -import -trustcacerts -alias INTER -file
AddTrustExternalCARoot -keystore hanbiro.key
keytool -import -trustcacerts -alias hanbiro -file
www_hanbiro.crt -keystore hanbiro.key
##주의##
Free SSL 및 PostiveSSL 의 경우, PostiveSSLCA.crt 파일을 추가 하지 않았을 경우,
아래와 같은 메세지가 표시 되며 저장 되지 않으니 반드시 아래 작업을 진행하여 주시기 바랍니다.
또한 -alias 설정시 .등의 특수문자가 있을 경우 인증서를 적용할 수 없습니다.
예) keytool -import -trustcacerts -alias www.hanbiro.com -file PositiveSSLCA.crt -keystore hanbiro.key (X)
keytool -import -trustcacerts -alias wwwhanbirocom -file PositiveSSLCA.crt -keystore hanbiro.key (0)
에러내용
keytool error: java.lang.Exception: Failed to establish chain from reply
추가내용
keytool -import -trustcacerts -alias POSITIVESSL -file PositiveSSLCA.crt -keystore hanbiro.key
5. 서버설정
Server.xml을 설정합니다.
# Tomcat 버젼 7.X 의 경우..
< — Define a SSL Coyote HTTP/1.1 Connector on port 8443 –>
<Connector port=”8443″
   maxThreads=”200″
   scheme=”https” secure=”true” SSLEnabled=”true”
   keystoreFile=”키스토어파일경로/hanbiro.key” keystorePass=”(hanbiro.key 패스워드)” clientAuth=”false” sslProtocol=”TLS”
/>
# Tomcat 버젼 6.X 의 경우..
<!–Define a SSL Coyote HTTP/1.1 Connector on port 8443 –>
<Connector port=”443″
   maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″ enableLookups=”false” disableUploadTimeout=”true”
   acceptCount=”100″ debug=”0″ scheme=”https” secure=”true” SSLEnabled=”true”  clientAuth=”false” sslProtocol=”TLS”
   keystoreFile=”키스토어파일경로/hanbiro.key” keystorePass=”(hanbiro.key 패스워드)”
/>
# Tomcat 버젼 5.X 의 경우..
<!–Define a SSL Coyote HTTP/1.1 Connector on port 8443 –>
<Connector port=”443″
   maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″  enableLookups=”false” disableUploadTimeout=”true”
   acceptCount=”100″ debug=”0″ scheme=”https” secure=”true”  clientAuth=”false” sslProtocol=”TLS”
   keystoreFile=”키스토어파일경로/hanbiro.key”  keystorePass=”(hanbiro.key 패스워드)”
/>
# Tomcat 버전 4.X 의 경우.
<!– Define a SSL Coyote HTTP/1.1 Connector on port 8443 –>
<Connector className=”org.apache.coyote.tomcat4.CoyoteConnector” port=”443″ minProcessors=”5″ maxProcessors=”75″
  enableLookups=”true”  acceptCount=”100″ debug=”0″ scheme=”https” secure=”true”
  useURIValidationHack=”false” disableUploadTimeout=”true” />
<Factory className=”org.apache.coyote.tomcat4.CoyoteServerSocketFactory”
  clientAuth=”false” protocol=”TLS”  keystoreFile=”키스토어파일경로/hanbiro.key”  keystorePass=”(hanbiro.key 패스워드)”
/>
6. 톰캣 재시작