기계는 거짓말하지 않는다

libcurl curl_easy_perform() failed: SSL peer certificate or SSH remote key was not OK 오류 본문

C

libcurl curl_easy_perform() failed: SSL peer certificate or SSH remote key was not OK 오류

KillinTime 2023. 5. 27. 22:51

curl 라이브러리를 이용할 때 볼 수 있는 SSL 인증 관련 오류이다.

아래는 해결 방법들이다.

SSL Disable

Docs: CURLOPT_SSL_VERIFYPEER

 

CURLOPT_SSL_VERIFYPEER

CURLOPT_SSL_VERIFYPEER explained Name CURLOPT_SSL_VERIFYPEER - verify the peer's SSL certificate Synopsis #include   CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify); Description Pass a long as parameter to enable or disable. T

curl.se

아래와 같이 SSL 인증을 disable 할 수 있다.

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);

CA 인증서 추가

Docs: CURLOPT_CAINFO

 

CURLOPT_CAINFO

CURLOPT_CAINFO explained Name CURLOPT_CAINFO - path to Certificate Authority (CA) bundle Synopsis #include   CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path); Description Pass a char * to a null-terminated string naming a file holding o

curl.se

# 다운로드
wget https://curl.haxx.se/ca/cacert.pem
// 코드 추가
curl_easy_setopt(curl, CURLOPT_CAINFO,"cacert.pem");
Comments