Jost Do It.

그냥 IT해.

서버 및 환경/Git

[gitlab] server certificate verification failed 해결 (SSL 인증 문제)

그냥하Jo. 2024. 5. 8. 13:43
반응형

문제 상황

사내 gitlab 서버를 이전하면서 git 관련 명령(fetch, pull 등)을 하면 아래와 같이 server의 인증서 검증에 실패했다는 메시지가 발생했다.

git fetch

>> fatal: unable to access 'https://gitlab.xxxx.com/financial_backend/us_stock_processing/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

 

 

그리고 해당 도메인으로 POST 명령 시에도 Peer's Certificate issuer is not recognized. 에러 메시지가 발생한다.

curl -v https://gitlab.xxxx.com 

>>>
* About to connect() to gitlab.xxxx.com port 443 (#0)
*   Trying 10.1.250.246...
* Connected to gitlab.xxxx.com (10.1.250.246) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* Server certificate:
*       subject: CN=*.xxxx.com
*       start date:  1월 19 00:00:00 2024 GMT
*       expire date:  2월 16 23:59:59 2025 GMT
*       common name: *.daumsoft.com
*       issuer: CN=RapidSSL TLS RSA CA G1,OU=www.digicert.com,O=DigiCert Inc,C=US
* NSS error -8179 (SEC_ERROR_UNKNOWN_ISSUER)
* Peer's Certificate issuer is not recognized.
* Closing connection 0
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

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.

 

 

원인

서버를 이전하면서 gitlab 서버가 들고 있는 인증서 정보를 로컬의 인증서와 일치하지 않아 발생하는 에러이다.

이 경우 다음 두가지 방법으로 해결할 수 있다.

 

1. gitlab에서 ssl 인증 무시하기

 

2. 서버로부터 pem 파일(인증서)을 직접 받아 로컬에 등록

 

 

해결 방법

 

1. gitlab에서 ssl 인증 무시하기

이 방법은 간단하게 gitlab 작업시 ssl 인증 과정을 무시하게 옵션을 설정한다.

git config --global http.sslverify false

export GIT_SSL_NO_VERIFY=true

 

 

 

2. gitlab 서버로부터 pem 파일(인증서)을 직접 받아 로컬에 등록

gitlab에서 사용하고 있는 인증서를 직접 받아서 서버에 등록할 수 있다.

 

아래는 Ubuntu 환경에서 적용하는 방법이다.

1) 먼저 gitlab 서버가 사용하는 인증서 파일(.pem)을 로컬의 /etc/ssl/certs에 옮겨준다.

sudo cp {인증서경로}/gitlab_{cert,key}.pem /etc/ssl/certs/.

 

2) 로컬 인증서 정보 업데이트

sudo update-ca-certificates

 

3) 기존 문제가 발생하던 레포에서 정상 동작하는지 확인하기

cd {git repo 경로}
git fetch

 

 

CentOS는 pem 파일을 옮길 경로와 명령어가 아래처럼 차이가 있다. 

1) gitlab 서버가 사용하는 인증서 파일(.pem)을 로컬의 /etc/pki/ca-trust/source/anchors 에 옮겨준다.

sudo cp {인증서경로}/gitlab_{cert,key}.pem  /etc/pki/ca-trust/source/anchors/.

 

2) 로컬 인증서 정보 업데이트

sudo sudo update-ca-trust

 

3) 기존 문제가 발생하던 레포에서 정상 동작하는지 확인하기

cd {git repo 경로}
git fetch

 

 

여담

1번이 간단하지만 서버에서 gitlab과 함께 gitlab-runner와 같은 ci/cd 툴도 사용중이어서 옵션을 각각 설정해주기 번거로워 2번 방법으로 인증서 등록을 진행했다.

 

참고

반응형