SSL/TLS

HTTPS 연결에서 TLS가 어디서 종료되는지, 인증서 체인과 제품별 설정을 어떻게 확인하는지 정리한다.


TLS가 끝나는 지점

Client --HTTPS--> Web Server --HTTP or HTTPS--> WAS

TLS의 의미

SSL/TLS는 클라이언트와 서버 사이 통신을 암호화하고, 서버의 신원을 인증하는 계층이다.

먼저 판단할 것

HTTPS 설정에서 가장 먼저 볼 것은 “TLS가 어디서 종료되는가”다.

구조설명
Web Server terminationNginx/Apache에서 HTTPS 종료, 내부 WAS는 HTTP
End-to-end TLSWeb Server와 WAS 사이도 HTTPS
LB terminationLoad Balancer에서 HTTPS 종료, 뒤쪽은 HTTP
TLS passthrough앞단은 TCP 전달만 하고 WAS 또는 backend가 TLS 종료

가장 흔한 구조는 Web Server termination이다.

Client --HTTPS:443--> Nginx/Apache --HTTP:8080--> Tomcat

인증서 구성

항목설명
Server Certificate도메인에 발급된 서버 인증서
Intermediate Certificate루트와 서버 인증서를 이어주는 중간 인증서
Root CA클라이언트가 신뢰하는 최상위 인증기관
Private Key서버 인증서와 짝이 되는 개인키. 외부 유출 금지
Full Chain서버 인증서와 중간 인증서를 합친 체인 파일

브라우저에서 인증서 오류가 나면 도메인 불일치, 만료, 체인 누락, 신뢰되지 않은 CA, 시간 불일치 등을 확인한다.

Nginx 예시

server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate     /etc/nginx/ssl/example.fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/example.key;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

HTTP를 HTTPS로 넘길 때는 별도 server block을 둔다.

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

Apache HTTP Server 예시

<VirtualHost *:443>
    ServerName example.com

    SSLEngine on
    SSLCertificateFile /etc/httpd/ssl/example.crt
    SSLCertificateKeyFile /etc/httpd/ssl/example.key
    SSLCertificateChainFile /etc/httpd/ssl/chain.crt

    ProxyPass "/" "http://127.0.0.1:8080/"
    ProxyPassReverse "/" "http://127.0.0.1:8080/"
</VirtualHost>

배포판과 Apache 버전에 따라 chain 설정 방식은 다를 수 있다. 운영 중인 버전의 문서를 확인한다.

WAS가 알아야 하는 것

TLS가 Web Server에서 종료되면 WAS 입장에서는 HTTP 요청처럼 보일 수 있다. 애플리케이션이 HTTPS redirect, secure cookie, callback URL을 다룬다면 원래 요청이 HTTPS였다는 정보를 전달해야 한다.

주로 다음 헤더를 사용한다.

헤더의미
X-Forwarded-Proto원래 요청 프로토콜
X-Forwarded-Host원래 Host
X-Forwarded-Port원래 포트

점검 명령

openssl s_client -connect example.com:443 -servername example.com
curl -Iv https://example.com
nginx -t
httpd -t

인증서 만료일만 빠르게 볼 수도 있다.

openssl x509 -in example.crt -noout -dates

장애 유형

증상확인 지점
인증서 만료notAfter
도메인 불일치CN/SAN에 요청 도메인이 있는가
체인 오류intermediate/fullchain 구성
mixed contentHTTPS 페이지에서 HTTP 리소스 호출
redirect loopWeb Server와 WAS가 서로 HTTPS redirect 처리
secure cookie 문제X-Forwarded-Proto, application proxy 설정

관련 블로그 기록

닫기 전 질문

  • TLS는 LB, Web Server, WAS 중 어디서 종료되는가?
  • 인증서 파일과 개인키는 어느 서버에 있으며 권한은 안전한가?
  • WAS가 원래 요청이 HTTPS였다는 사실을 알 수 있는가?