Amazon RDS and Amazon Aurora SSL/TLS 인증서를 업데이트 후 별다른 설정 변경을 하지 않았지만, 오랜만에 빌드하는 스프링부트 프로젝트의 데이터베이스 연결이 되지 않는 현상 발생하였다.  

[### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host “{host}”, user “{user}”, database “{database}”, no encryption ]  

RDS 인증서 업데이트 작업 후 SSL 요구설정이 활성화된 것으로, 해당 에러가 나며 접속이 안된다면 다음과 같이 조치할 수 있다.

1. sslmode=require 속성을 추가

별도 인증서를 지정하지 않아도 다음과 같이 간단한 속성 추가로 문제를 해결할 수 있다.

jdbc.url=jdbc:postgresql://{url}:{port}/{database}?sslmode=require

2. SSL 인증서를 지정

AWS RDS의 SSL 인증서 번들을 다운로드 받은 후 접속 파라미터 혹은 스프링부트 시스템 속성에 추가해 주면 된다. 다음은 접속 파라미터에 추가하는 예제이다.

jdbc.url=jdbc:postgresql://{url}:{port}/{database}?ssl=true&sslmode=require&sslrootcert={인증서경로}.pem