본문 바로가기

머리가 안좋으면 공부라도/업무 경험

Https 인증서 오류 및 해결방안

1. Https 인증서 오류 발생 경위

   1)  어플리케이션 소스 패치 작업을 위하여 pod 내부 tomcat에 war image 교체 후 was 재기동

   2)   SAML 2.0 SSO 연동과 관련된 metadata load 및 객체 생성 중 오류 발생

   3)  해당  bean 객체  생성 중 오류 발생으로 인한 어플리케이션 구동 불가

 

 2. 원인 파악

  1)  SAML 소스 내부 metadata load 로직 변경 사항 없음

  2) 정상적으로 패치를 진행하였던 이전 버전의 소스 또한 구동 불가

  3) 개발서버에서 Https 인증서 변경됨이 확인 

  4) Https 인증서 변경 이전 버전에서는 정상적으로 구동

 

3. SAML 연동 방식에 따라 Https 인증서 발생 여부 확인

 

  1) OpenSAML 방식

     => Java 기본 네트워크 라이브러리를 통해 IdP 접속

     => Java는 공인된 기관(CA)에서 발급한 인증서만 신뢰, 사설 인증서를 사용하거나 로컬 테스트 환경인 경우 통신이 거부

     => JVM 실행 환경의 Truststore 인증서가 없을 경우 즉시 PKIX 오류 발생

     => 애플리케이션 초기화 단계에서 구동 중단으로 이어짐

 

  2) Spring Security 방식

     => Spring Security 제공하는 추상화된 보안 설정 사용, JKS 파일을 직접 지정하여 Java Truststore 의존도 낮음

     => Idp 쪽 SSL 인증서 변경에 대한 영향이 적음

 

 

4. 해결 방안 

 

  1) Java Truststore IdP 인증서 추가

     =>  직접 인증서를 브라우저를 통해 다운로드 후 JDK의 cacerts 파일에 인증서 등록

 

  2) SSL 인증서 검증 우회

     => SSL 검증을 비활성화하여 인증서 오류 무시

     => 단점 : 보안 취약점 발생 가능 및 운영 환경 적용 부적합

 

  3) . IdP Metadata 파일을 로컬로 관리

      => URL로 SAML idp metadata를 가져오는 것이 아닌 직접 해당 파일을 다운로드 하여 프로젝트 내부에 저장하여

           해당 정보로 객체 생성

      => 단점 : Idp Metadata가 변경될 때마다 재다운로드 및 was 재기동 필요

 

 

 5. SSL 인증서 검증 우회 관련 javax pacakge 및 객체 정리 (Java 17 기준)

 

  1) java.net.ssl package 

     => Provides classes for the secure socket package.

     => Using the secure socket classes, communicating using SSL or a related security protocol to reliably detect any                  erros introduced into the network byte stream 

     => Optionally encrypt the data and/or authenticate the communicating peers

 

  2) HttpsURLConnection
     =>  HttpsURLConnection extends httpURLConnection with the support for https-specific features

     =>  using HostnameVerifier and SSLSocketFactory.

     => this implementations can be replcaed on a per class (static) or per-instance basis

     => new HttpsConnections instances will be assigned the default static values at instance creation, but they can be                 overriden by  calling the appropriate per-instance set method before connecting

  

   3) SSLContext 

     => A secure socket protocol implementation which acts as  a factory for secure socket  factories or SSLEngines

     => initialized with an optional set of key and trust managers and source of secure random bytes

     => Every implementation of the Java platform is required to support the following standart SSLContext  protocol

  

   4) TrustManager 

     => TrustManagers are responsible for managing the trust material that is used when making trust decisions, and for              deciding whether credentials presented by a peer should be accepted

     => TrustManagers are created by either using a TrustManagerFactory, or by implementing one of                                             the TrustManager subclasses

 

   5) X509TrustManager 

      => Managing X509  instance

 

 

참조 : https://docs.oracle.com/en/java/javase/17/docs/api/java.base/javax/net/ssl/package-summary.html

'머리가 안좋으면 공부라도 > 업무 경험' 카테고리의 다른 글

RAG (Retrieval-Augmented Generation)  (0) 2026.01.20
ResultSetMetaData  (0) 2026.01.19