[api] HTTPS URL에 액세스하는 동안 cURL을 사용하여 인증서를 처리하려면 어떻게해야합니까?

curl을 사용하여 다음 오류가 발생합니다.

컬 : (77) 오류 설정 인증서 확인 위치 :
  CA 파일 : /etc/ssl/certs/ca-certificates.crt
  경로 : 없음

이 인증서 확인 위치를 어떻게 설정합니까? 감사.



답변

이 오류는 관련이 누락 된 패키지 : ca-certificates. 설치하십시오.

우분투 리눅스 (및 유사한 배포판)에서 :

# apt-get install ca-certificates

Apt-Cyg 를 통한 CygWin에서

# apt-cyg install ca-certificates

아치 리눅스에서 (Raspberry Pi)

# pacman -S ca-certificates

설명서는 다음을 알려줍니다.

이 패키지에는 SSL 기반 응용 프로그램이 SSL 연결의 진위 여부를 확인할 수 있도록 CA 인증서의 PEM 파일이 포함되어 있습니다.

보시다시피 : 데비안-스퀴즈에서 패키지 인증서의 세부 사항


답변

최신 버전의 ca-certificates도 설치했지만 여전히 오류가 발생했습니다.

curl: (77) error setting certificate verify locations:
  CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none

curl은 인증서가 경로에있을 것으로 예상 /etc/pki/tls/certs/ca-bundle.crt했지만 경로에 있었기 때문에 인증서를 찾을 수 없다는 문제가있었습니다 /etc/ssl/certs/ca-certificates.crt.

다음을 실행하여 인증서를 예상 대상으로 복사

sudo cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt

나를 위해 일했다. 대상 대상 폴더가없는 경우이를 실행하여 폴더를 만들어야합니다.

sudo mkdir -p /etc/pki/tls/certs

필요한 경우, 위의 명령을 수정하여 대상 파일 이름이 curl에서 예상되는 경로와 일치하도록하십시오 (예 /etc/pki/tls/certs/ca-bundle.crt: 오류 메시지에서 “CAfile :”다음의 경로로 바꾸 십시오).


답변

이것을 당신의 것으로 .bashrc

# fix CURL certificates path
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

(로버트의 의견 참조)


답변

~/.curlrc다음 내용 으로 파일 을 작성하십시오.

cacert=/etc/ssl/certs/ca-certificates.crt


답변

오류를 해결하는 가장 빠른 방법은 curl 요청의 어딘가에 -k 옵션을 추가하는 것입니다. 이 옵션은 “인증없이 SSL 인용에 연결할 수 있습니다.” (컬-도움말에서)

이는 신뢰할 수있는 CA에서 서명하지 않은 인증서를 제시하므로 자신이 생각하는 엔드 포인트와 대화하고 있지 않음을 의미 할 수 있습니다.

예를 들면 다음과 같습니다.

$ curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg

나에게 다음과 같은 오류 응답을 주었다.

curl: (77) error setting certificate verify locations:
  CAfile: /usr/ssl/certs/ca-bundle.crt
  CApath: none

-k에 추가했습니다.

curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg -k

오류 메시지가 없습니다. 보너스로 apt-cyg가 설치되었습니다. 그리고 ca 인증서.


답변

@roens가 정확합니다. 이것은 아래 오류와 함께 모든 Anaconda 사용자에게 영향을 미칩니다
curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

해결 방법은 기본 시스템 컬을 사용 하고 앞에 추가 된 Anaconda 변수 를 사용 하지 않는 것입니다 PATH. 당신은 할 수 있습니다

  1. Anaconda curl 바이너리의 이름을 바꾸십시오 🙂
    mv /path/to/anaconda/bin/curl /path/to/anaconda/bin/curl_anaconda

  2. 또는 Anaconda curl 제거
    conda remove curl

$ which curl
/usr/bin/curl

[0] Anaconda Ubuntu curl Github 문제 https://github.com/conda/conda-recipes/issues/352


답변

보낸 사람 $ man curl:

--cert-type <type>
    (SSL) Tells curl what certificate type the provided  certificate
    is in. PEM, DER and ENG are recognized types.  If not specified,
    PEM is assumed.

    If this option is used several times, the last one will be used.

--cacert <CA certificate>
    (SSL) Tells curl to use the specified certificate file to verify
    the peer. The file may contain  multiple  CA  certificates.  The
    certificate(s)  must be in PEM format. Normally curl is built to
    use a default file for this, so this option is typically used to
    alter that default file.