운영체제/Linux

[Linux] sectigo root/chain 인증서 추가

louky 2020. 1. 28. 17:31
반응형

 

SSL 인증서 중 Comodo  인증서가  sectigo 인증서로 변경 되면서 일부 리눅스 시스템 내 Root/chain 인증서가 반영이 안되어 있어 JAVA SSL HandshakeException  및  curl 오류가 아래와 같이 발생한다. 

 

간단히 curl명령어를 통해서도 확인이 가능하다.

 

curl: (60) Peer's Certificate issuer is not recognized.

[root@test1 ~]# curl https://test.com/index.php
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

 

[root@test ~]# curl -v https://test.com:443/test.php
* About to connect() to test.com port 443 (#0)
*   Trying 1.x.x.x...
* Connected to test.com (1.x.x.x) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* Server certificate:
*   subject: CN=test.com
*   start date: 12월 20 00:00:00 2019 GMT
*   expire date: 12월 19 23:59:59 2020 GMT
*   common name: test.com
*   issuer: CN=Sectigo RSA Domain Validation Secure Server CA,O=Sectigo Limited,L=Salford,ST=Greater Manchester,C=GB
* NSS error -8179 (SEC_ERROR_UNKNOWN_ISSUER)
* Peer's Certificate issuer is not recognized.
* Closing connection 0
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

 

curl의 -v옵션을 통해 시스템내 어느 root 인증서 파일을 참고 하는지 확인 할 수 있다. 

 CAfile: /etc/pki/tls/certs/ca-bundle.crt 

 

또는  JAVA에서는 아래와 같은 오류가 발생 할 수 있다.  ( SSL HandShakeException error)

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

필자가 마지막까지 확인한 결과 Centos 기준 7.7까지는 Linux 시스템내에 수동으로   sectigo root인증서를 수동으로 추가를 해줘야 sectigo인증서를 사용하는 서버와의 통신에 문제가 생기지 않는 다는 것을 확인하였다. 

 

Sectigo root/chain인증서를 리눅스 시스템내 수동으로 추가 하는 방법은 아래와 같다. 

먼저 Sectigo  root/chain 인증서를 다운로드한다. 

 

sectigo_cert.zip
0.03MB

 

다운로드는 아래 경로에서 하거나 첨부된 파일을 다운로드한다.

(첨부된 파일이 의심된다고 생각한다면 아래 링크를 선택하여 다운로드 한다. )

https://www.certkorea.co.kr/bbs/board.php?bo_table=31&wr_id=30

 

[공지] Comodo -> Sectigo 브랜드 변경에 따른 루트/중개 인증서 변경 공지 > 공지사항 | SSL 인증서 전문 써트코리아- ssl.co.kr - 보안서버,웹서버, SSL, Symantec프리미엄제휴사

> 고객지원/이벤트 > 공지사항 공지사항

www.certkorea.co.kr

 

다운로드한 파일을 압축을 해제 한다. 

 

# unzip sectigo_sert.zip

 

**  unzip  명령어가 실행되지 않을 경우 아래 링크를 통해 설치 한다.

2018/10/11 - [운영체제/Linux] - [Linux] zip/unzip 압축파일 패스워드 설정하기

 

압축을 해제한 디렉토리로 이동한다. 

# cd RSA
[root@test RSA]# ls -al
total 28
drwxr-xr-x 6 root root 4096 Jan 28 07:02 .
drwxr-xr-x 3 root root 4096 Jan 22 07:37 ..
drwxr-xr-x 2 root root 4096 Jan 23 01:58 Sectigo_RSA_AddTrust_Codesign
drwxr-xr-x 2 root root 4096 Jan 28 05:02 Sectigo_RSA_AddTrust_DV
drwxr-xr-x 2 root root 4096 Jan 28 06:25 Sectigo_RSA_AddTrust_EV
drwxr-xr-x 2 root root 4096 Jan 22 07:37 Sectigo_RSA_AddTrust_OV

압축해제한 디렉토리에 보면  SSL레벨별로 파일이 달리 되어 있으므로 추가 대상을 확인한다. 

필자는 sectigo에서 지원하는 root/chain을 모두 추가 하였지만 특정 SSL레벨만 추가 하고자 한다면 curl -v를 통해 나온 결과 중 아래 표시된 부분을 참고하여 해당 SSL레벨로 설치하면 된다. 

 

issuer: CN=Sectigo RSA Domain Validation Secure Server CA,O=Sectigo Limited,L=Salford,ST=Greater Manchester,C=GB

 

 

 

원본 root/chain 인증서 파일을 백업한다.  (링크 파일 일 경우 링크 파일을 기준으로 작업을 진행한다.)

# /bin/cp -rpRf /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.orig_$(date '+%Y%m%d')

 

인증서 구분을 위해 아래와 같이 주석을 추가 한다. 

#  printf "\n### Sectigo_RSA_AddTrust_Codesign Add $(date '+%Y.%m%.d') \n " >> /etc/pki/tls/certs/ca-bundle.crt

**printf가 아닌  echo를 사용해도 된다. 

 

추가하고자 하는 SSL레별로 이동하여 "Chain_RootCA_Bundle.crt" 을 리다이렉션하여 기존 "/etc/pki/tls/certs/ca-bundle.crt"에 추가 한다. 이때 개행 문자로 인해 정상적으로 인식이 안될 수 있으므로 개행문자(^M)를 제거하는 옵션을 추가 하여 리다이렉션을 한다.

 

**개행 문자를 제거하는 방법은 다양하겠지만 필자는 아래와 같이 sed옵션을 통해 제거 하였다. 

# cat Chain_RootCA_Bundle.crt | sed -e "s/\\r//g" >> /etc/pki/tls/certs/ca-bundle.crt

 

이후 curl 명령어를 통해 동작여부를 확인한다. 

[root@test certs]# curl https://test.com:443/test.php
<pre></pre>

test test 

 

<비교 - SSL오류 시 >

[root@test ~]# curl https://test.com:443/test.php
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

 

일단 간단히 curl 을 통해 시스템내에 인증서 추가 후 확인 방법에 대한 것이며  JAVA의 경우 아래방법을 참고 한다. 

 

<출처 : https://www.securesign.kr/guides/kb/47 >  -  문제가 될 경우 삭제 하겠습니다. 

 

 

Tip!!!!

시스템마다 조금씩 상이 하겠지만 Linux Centos 7.7 기준으로 Sectigo의 모든 root 인증서를 추가 하고자 한다면 첨부된 "add_sectigo_cert.sh"파일을 다운로드하여 sectigo 인증서 압축해제한 디렉토리 내 RSA디렉토리 하위에 저장하고 실행한다.

(script는 그냥 필자가 편한대로 작성한거니 딴지는 사양합니다. )

[root@test RSA]# ls -al
total 28
drwxr-xr-x 6 root root 4096 Jan 28 07:02 .
drwxr-xr-x 3 root root 4096 Jan 22 07:37 ..
-rwxr-xr-x 1 root root 1389 Jan 28 07:02 add_sectigo_cert.sh
drwxr-xr-x 2 root root 4096 Jan 23 01:58 Sectigo_RSA_AddTrust_Codesign
drwxr-xr-x 2 root root 4096 Jan 28 05:02 Sectigo_RSA_AddTrust_DV
drwxr-xr-x 2 root root 4096 Jan 28 06:25 Sectigo_RSA_AddTrust_EV
drwxr-xr-x 2 root root 4096 Jan 22 07:37 Sectigo_RSA_AddTrust_OV

 

add_sectigo_cert.sh
0.00MB

 

반응형