Curl: (60) Peer certificate cannot be authenticated with known CA certificates

Summary

While running an ongoing terminal scan with the SVM Agent for Linux, the latter returns the following:

"error while checking in with server (60) ... connection error"This error is related to the server SSL certificate which in this case had not yet been imported in the 'trusted certificates list' of the Linux server system. The error message says the following:

"Peer's certificate issuer had been marked as not trusted by the user" 

Symptoms

While running a scan with the Software Vulnerability Manager Agent for Red Hat Linux, the latter returns:

"Error while checking in with server (60)" message and "connection error" known as 'curl 60'.

Curl: (60) Peer certificate cannot be authenticated with known CA certificates

You might see this error in the "sync.log" log file of your RHEL/CentOS SVM server, printed out with the following message:

"There was a problem with the curl request. Error no 60: Peer certificate cannot be authenticated with known CA certificates"

Cause

The error indicates that the 'Certification Authorities' list on the Redhat machine does not include a reference to the SSL certificate which your server instance is using to authorize SSL connections.  

You should copy the public-key copy of your certificate to your Redhat machine and import it to the list of trusted certification authorities (ca-bundle.crt)

Resolution

1. Open Internet Explorer on a Windows host and type in the browser the name of your server (https://).
2. Once connected, click on the lock icon on the right side of the address bar, click 'View Certificates'.
3. Click on Details TAB.
4. Click 'Copy to File' > Next > 'Base-64 encoded x.509 (.CER)' > Next > Save (e.g. rhel7-server-public.CER).

Curl: (60) Peer certificate cannot be authenticated with known CA certificates
5. Transfer the.CER file to your Redhat server (e.g. /home/user/temp directory).
6. Run this command to import the certificate in the trusted CA's list:

cat rhel7-server-public.CER >> /etc/pki/tls/certs/ca-bundle.crt


After you performed these actions, you should be able to run an error-free scan with the SVM Agent.

안녕하세요.

회사 같은 환경에서는 외부 네트워크가 연결되어 있다 하더라도 SSL 인증 문제로 yum 사용이 어려울 수 있습니다.

yum 으로 패키지 설치를 하고 싶은데 다음과 같은 문제가 나올 수 있습니다.

Curl error (60): Peer certificate cannot be authenticated with given CA certificates for ...... [SSL certificate problem: unable to get local issuer certificate]

이럴 때는 간단하게 해결이 가능 합니다.

yum repository 설정 파일 (/etc/yum.repos.d/ 디렉토리에 있는 .repo 파일)에 다음의 내용을 추가 해주면 됩니다.

sslverify=0

이러면 SSL 인증을 무시하고 설치 하게 됩니다.

Skip to content

Getting an error “curl: (60) Peer certificate cannot be authenticated with known CA certificates” when trying to curl a site that has a VALID SSL certificate

Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crtcurl 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. curl --noproxy -k \* -D - https://127.0.0.1:443/some-secure-endpoint 

curl 은 기본적으로 https 사이트의 SSL 인증서를 검증한다. 인증 기관의 인증서 목록이 없거나 모르는 기관에서 발급한 인증서일 경우 다음과 같은 인증서 검증 에러를 발생시키고 동작을 중지하게 된다.

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

BASH

해결방법은 3가지가 있다.

1. 인증서 검증 안 함

검증을 하지 않는 옵션인 -k(--insecure) 옵션을 주고 curl 을 구동하면 된다.

curl -k -L google.com

BASH

curl --insecure -L google.com

BASH

2. 인증기관 목록 추가하기

2번째 방법은 curl 의 신뢰하는 인증 기관 목록(CA List; Certificate Authority List)에 접속하려는 사이트의 인증서를 발급한 기관을 추가하는 방법이다.

1.  먼저 curl 을 -v 옵션을 주고 실행해서 CA List 파일이 어디에 있는지 위치를 확인한다.

RHEL/CentOS 는 아래와 같이 /etc/pki/tls/certs/ca-bundle.crt 에서 CA 목록을 로딩함

lesstif@localhost:~> curl -v https://google.com   * About to connect() to google.com port 443 (#0) * Trying 74.125.128.139... connected * Connected to google.com (74.125.128.139) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none

BASH

Ubuntu 는 /etc/ssl/certs/ca-certificates.crt 또는  /etc/ssl/certs 디렉터리에서 CA 목록 로딩

Windows 에서 curl.exe 를 사용시 다음 순서대로 ca-bundle.crt 를 찾음

  1. application's directory
  2. current working directory
  3. Windows System directory (e.g. C:\windows\system32)
  4. Windows Directory (e.g. C:\windows)
  5. all directories along %PATH%

2. 서버 인증서 및 CA List 를  BASE64 로 저장한 내용을 위에서 확인한 ca-bundle.crt 파일에 추가해 준다. 자세한 방법은 https 연결시 서버의 SSL 인증서 추출하기 (curl 또는 web browser 사용) 를 참고한다.

3. 런타임에 옵션으로 CA List 파일을 지정하려면 curl 실행시 --cacert  옵션으로 CA  List를 지정할 수 있다.

curl -v --cacert myca-bundle.crt https://google.com

BASH

3. CA 인증서 파일 갱신

새로운 인증 기관이 생겼는데 OS 에 포함된 curl 에는 반영이 안 되서 발생할 수 있다. curl 홈페이지에서는 주기적으로 최신 인증 기관 목록을 갱신햇 배포하므로 CA 인증서 목록을 다운받아서 기존 파일에 덮어써도 된다.

1. wget 또는 curl  명령을 사용해서 https://curl.haxx.se/ca/cacert.pem 에서 인증서를 다운받는다. 

wget 사용

wget --no-check-certificate https://curl.haxx.se/ca/cacert.pem

BASH

curl 사용

curl -k -O https://curl.haxx.se/ca/cacert.pem

CODE

2. curl -v 옵션으로 CA 인증서 목록 파일의 위치를 확인한 후에 예전 파일은 백업하고 다운받은 인증서 파일을 덮어쓴다.

curl 사용

sudo cp cacert.pem  /etc/ssl/certs/ca-certificates.crt 

CODE

PHP 에서 curl 사용시

Guzzle - cURL error 60: SSL certificate problem: unable to get local issuer certificate 문제 해결 을 참고

같이 보기

  • java keytool 사용법 - Keystore 생성, 키쌍 생성, 인증서 등록 및 관리
  • Guzzle - cURL error 60: SSL certificate problem: unable to get local issuer certificate 문제 해결
  • git 에서 https repository 연결시 SSL 인증서 오류 해결법
  • Java 에서 ValidatorException 등 인증서 관련 에러 해결 - keystore에 SSL/TLS 인증서를 import 하기
  • SSL Intermediate 인증서 모음(github gist)



How do I fix peer certificate Cannot be authenticated with given CA certificates?

It can be caused by the fact that the certificate is self-signed. To avoid the error, disable the verification from the GitHub side by clicking the Disable SSL verification button for the corresponding webhook.

How do I fix curl Error 60?

Solution:.
Save the cacert. pem file anywhere on your system. Example: Since you're modifying both php. ... .
Open your php.ini file. If your php.ini file doesn't have the curl.cainfo line, just add it to the end of the file, then add the file path where you saved your cacert.pem file: ... .
Restart your server..

Does Curl use CA certificates?

libcurl performs peer SSL certificate verification by default. This is done by using a CA certificate store that the SSL library can use to make sure the peer's server certificate is valid.

What is curl 60 error?

Error “curl: (60) SSL certificate problem: unable to get local issuer certificate” can be seen when the SSL certificate on the server is not verified or properly configured.