본문 바로가기

리눅스

SSL 인증서 합치기(nginx 인증서 생성)

728x90

SSL 인증서 합치기(nginx 인증서 생성)

  • Sectigo(COMODO)
    • COMODO ROOT CA : 최상위 인증서
    • COMODO Chain CA : 중간 인증서

루트 인증서와 중간 인증서를 별도로 받은 경우

cat example_com.crt COMODO_RSA_Domain_Validation_Secure_Server_CA.crt COMODO_RSA_Certification_Authority.crt AddTrust_External_CA_Root.crt >> unified_example_com.crt

번들(bundle) 파일로 중간 인증서를 받은 경우

cat example_com.crt example_com.ca-bundle.pem >> unified_example_com.crt

SSL 인증서 합치기

  • 기관으로부터 발급받은 인증서(apache 서버용)
$ ls -l
total 24
-rw-r--r-- 1 root root 4134 Sep 30 12:54 rsa-dv.chain-bundle.pem
-rw-r--r-- 1 root root 2268 Sep 30 12:54 _wildcard_scbyun_com.crt
-rw-r--r-- 1 root root 7608 Sep 30 12:54 _wildcard_scbyun_com.pfx
-rw-r--r-- 1 root root 1702 Sep 30 12:54 _wildcard_scbyun_com_SHA256WITHRSA.key
  • 인증서 파일 통합

cat _wildcard_scbyun_com.crt(서버인증서) rsa-dv.chain-bundle.pem(체인+루트) >> _unified_wildcard_scbyun_com.crt

cat _wildcard_scbyun_com.crt rsa-dv.chain-bundle.pem >> _unified_wildcard_scbyun_com.crt
  • 인증서 파일 목록
$ ls -l
total 12
-rw-r--r-- 1 root root 6470 Jan  4 10:04 _unified_wildcard_scbyun_com.crt
-rw-r--r-- 1 root root 1702 Sep 30 12:54 _wildcard_scbyun_com_SHA256WITHRSA.key

웹 서버 설정

  • nginx vitualhost 설정
server {
    listen 80;
    server_name scbyun.com www.scbyun.com;
    return 301 https://$host$request_uri;
    charset utf-8;
}

server {
    listen 443 ssl http2;
    server_name scbyun.com;
    root /var/www/html/public;
    index index.php index.html;

    access_log /var/log/nginx/scbyun.com-accesss.log;
    error_log /var/log/nginx/scbyun.com-error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    # pass PHP scripts to FastCGI server
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    ssl_certificate "/etc/nginx/ssl/_unified_wildcard_scbyun_com.crt";
    ssl_certificate_key "/etc/nginx/ssl/_wildcard_scbyun_com_SHA256WITHRSA.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
728x90
  • Apache VirtualHost
<VirtualHost *:443>
  ServerName "지정한 서버인증서에 포함(지원)된 도메인"
  
  SSLEngine on
  SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 (서버 환경에 따라서 선택적 적용)
  SSLCertificateKeyFile /인증서파일경로/개인키 ex. sslcert.co.kr_xxxxx.key.pem
  SSLCertificateFile /인증서파일경로/서버인증서 ex. sslcert.co.kr_xxxxx.crt.pem
  SSLCertificateChainFile /인증서파일경로/체인인증서ex. chain-bundle.pem
  SSLCACertificateFile /인증서파일경로/루트인증서 ex. AAACertificateServices.Root.crt.pem
</VirtualHost>
  • Apache 2.4.8+ VirtualHost
<VirtualHost *:443>
  ServerName "지정한 서버인증서에 포함(지원)된 도메인"
  
  SSLEngine on
  SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 (서버 환경에 따라서 선택적 적용)
  SSLCertificateKeyFile /인증서파일경로/개인키 ex. sslcert.co.kr_xxxxx.key.pem
  SSLCertificateFile /인증서파일경로/서버인증서 ex. sslcert.co.kr_xxxxx.crt.pem
  SSLCACertificateFile /인증서파일경로/루트,체인 통합 파일 ex. ca-chain-bundle.pem
</VirtualHost>
  • Nginx VirtualHost
server {
  listen 443; (1.15 버젼 부터는 listen 443 ssl; 형식으로 변경됨)
  server_name www.sslcert.co.kr; (지정한 서버인증서에 포함(지원)된 도메인)
  
  ssl on; (1.15 버젼 부터는 옵션 지원 종료)
  ssl_certificate_key /파일경로/sslcert.co.kr_xxxxx.key.pem; (개인키 파일 지정)
  ssl_certificate /파일경로/sslcert.co.kr_xxxxx.unified.crt.pem; (서버인증서+체인+루트 통합 unified 파일 지정)
  ssl_protocols TLSv1.2; (서버 환경에 따라 선택적 적용)
}

 

참고URL

- SSL Checker : https://decoder.link

- SecureSign-Apache : https://www.sslcert.co.kr/guides/Apache-SSL-Certificate-Install

- SecureSign-NginX : https://www.sslcert.co.kr/guides/NGINX-SSL-Certificate-Install

- WinCERT-SECTIGO 이전 코모도 중개인증서 변경 안내 : https://wincert.com/?c=blog&m=catrendreads&bbs_id=77bce2624229e631ca50a2e575de0b68e30f1a0d3ef8e7b7&schKeyword=&schStatus=&per_page=18

 

728x90

'리눅스' 카테고리의 다른 글

FTP(vsftp) 전송 모드(Active Mode/Passive Mode)  (0) 2023.01.06
watch 명령어  (0) 2023.01.05
리눅스 2TB 이상 디스크 사용하기(GPT 파티션 설정)  (0) 2023.01.03
Composer 설치 및 사용법  (0) 2023.01.03
growpart 명령어  (0) 2023.01.03