curl에서 SSL 인증서 검증 문제 해결 방법

 

문제

 

curl, URL과 함께 데이터를 전송하기 위한 명령어 툴을 사용하여 HTTPS 서버에서 데이터를 가져올 때, 서버의 SSL 인증서를 curl의 기본 번들 내의 인증 기관(CA) 인증서와 대조할 수 없으면 실패할 수 있습니다.

 

출력 에러는 아래와 같습니다.

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.

 

원인

 

1. curl이 사용하는 기본 CA 인증서 번들에는 서버의 인증서에 서명한 CA가 포함되어 있지 않습니다.

 

2. 서버의 인증서에 문제가 있습니다.

예를 들면:

  인증서가 만료되었거나, 

  인증서의 이름이 URL의 도메인 이름과 일치하지 않습니다.

 

해결책

 

대체 CA 번들 지정

신뢰하는 다른 CA 번들이 있다면, curl에 기본값 대신 해당 CA번들을 사용하도록 지시할 수 있습니다.

--cacert 옵션 뒤에 CA 번들 경로를 지정하시면 됩니다.

$ curl --cacert /경로/당신의/cabundle.pem https://example.com

 

인증서 검증 해제

서버의 무결성과 보안에 확신이 있다면 (예: 신뢰하는 내부 서버인 경우) curl에 인증서 검증을 건너뛰도록 지시할 수 있습니다. 이 작업은 -k 또는 --insecure 옵션을 사용하시면 됩니다.

$ curl -k https://example.com

 

경고

--insecure 옵션을 사용하면 중간자 공격에 노출될 수 있으므로, 거래나 민감한 작업에는 권장되지 않습니다.

댓글

Designed by JB FACTORY

loading