ISRG X1 인증서 강제 설치

ISRG X1 인증서 강제 설치

postgres 웹사이트에서 인증서 키를 가져올 때 오류가 발생하기 시작했습니다.

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
#6 0.310 --2021-10-04 20:56:35--  https://www.postgresql.org/media/keys/ACCC4CF8.asc
#6 0.315 Resolving www.postgresql.org (www.postgresql.org)... 87.238.57.232, 72.32.157.230, 217.196.149.50, ...
#6 0.318 Connecting to www.postgresql.org (www.postgresql.org)|87.238.57.232|:443... connected.
#6 0.902 ERROR: The certificate of 'www.postgresql.org' is not trusted.
#6 0.902 ERROR: The certificate of 'www.postgresql.org' has expired.

나는 다음을 사용하여 이 문제를 해결하려고 했습니다 --no-check-certificate.

apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    postgresql-client-common postgresql-client-13 \
    && rm -rf /var/lib/apt/lists/*

#9 2.579   404  Not Found [IP: 147.75.85.69 80]
#9 2.606 Fetched 7888 kB in 2s (3486 kB/s)
#9 2.606 Reading package lists...
#9 2.974 W: The repository 'http://apt.postgresql.org/pub/repos/apt -pgdg Release' does not have a Release file.
#9 2.974 E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/-pgdg/main/binary-arm64/Packages  404  Not Found [IP: 147.75.85.69 80]
#9 2.974 E: Some index files failed to download. They have been ignored, or old ones used instead.

이 문제를 해결할 다른 방법이 있나요? 오늘 갑자기 이런 일이 일어나기 시작했습니다.

답변1

PostgreSQL.org는 LetsEncrypt 서명 인증서(방금 확인함)를 사용하고 루트 인증서를 확인합니다.

인증서가 만료되었습니다.. 갱신되었지만 시스템에 CA 인증서가 없을 수 있으므로 시스템이 새 X1 인증서를 검증할 수 없으므로 이를 거부합니다.

내가 아는 한 HTTPS 업그레이드를 자동으로 수행하는 http 저장소에서도 동일한 일이 발생합니다. 이 업그레이드를 보고하는 적절한 내용이 표시되지 않으므로 시도했지만 자동으로 실패하고 실제 오류가 "파일을 검색하기 위해 연결할 수 없음"에 가깝다면 "해당 파일 없음" 오류가 발생하는 것 같습니다. 다음을 통해 확인할 수 있습니다.유효하지 않은 인증서를 무시하도록 지시.

하지만 당신이 해야 할 일은CA 인증서 업데이트. 업데이트에 "ca-certificate" 패키지가 있음을 알 수 있습니다. 일단 그것이 제자리에 있으면 다른 모든 것이 다시 작동하기 시작합니다.

ISRG X1 인증서 강제 설치

  • 얻다자격증(예를 들어 curl -k https://letsencrypt.org/certs/isrgrootx1.pem > isrgrootx1.pem)
  • CRT 추출openssl crl2pkcs7 -nocrl -certfile isrgrootx1.pem | openssl pkcs7 -print_certs -out isrgrootx1.crt
  • 에 복사하세요/usr/local/share/ca-certificates/
  • 달리기 sudo update-ca-certificates.

중복된 인증서가 보고되면 /etc/ssl/certs에서 찾아서 확인하세요. "subject=C=US,O=Internet Security Research Group,CN=ISRG Root X1"이면 ISGR X1 인증서가 이미 설치되어 있으므로 문제는 다른 곳에 있습니다.

답변2

~에 귀속됨LSerni가 나에게 올바른 방향을 알려줬어요. 제 경우에는 문제를 해결하기 위해 수행해야 할 단계가 한 가지 더 있습니다.분명히비활성화됨 mozilla/DST_Root_CA_X3.crt(사용됨 sed, 아래 참조 /etc/ca-certificates.conf)

또한 흥미로운 점은 Docker 를 사용하여 Docker에서 버그를 재현할 수 없지만 debian:stretchDocker 를 사용하면 버그를 재현할 수 있다는 것입니다 python:3.7.8-stretch.

버그를 재현하는 명령은 기본적으로 다음 세 가지입니다.

apt-get update && apt-get install -y lsb-release wget
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

위 명령을 실행하면 gpg: no valid OpenPGP data found.기본 문제인 출력이 생성됩니다.

오류를 재현하는 데 사용된 이미지 ID:

me@home$ docker images
REPOSITORY                        TAG             IMAGE ID       CREATED         SIZE
python                            3.7.8-stretch   b64658cdf594   14 months ago   902MB

오류를 재현하기 위한 출력:

me@home$ docker run -it python:3.7.8-stretch /bin/bash
root@771da843c08d:/# apt-get update && apt-get install -y lsb-release wget
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [53.0 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [93.6 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]           
Get:5 http://deb.debian.org/debian stretch Release.gpg [3177 B]                  
Get:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [720 kB]
Get:7 http://deb.debian.org/debian stretch/main amd64 Packages [7080 kB]         
Fetched 8067 kB in 1s (4448 kB/s)                     
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
wget is already the newest version (1.18-5+deb9u3).
Suggested packages:
  lsb
The following NEW packages will be installed:
  distro-info-data lsb-release
0 upgraded, 2 newly installed, 0 to remove and 106 not upgraded.
Need to get 32.9 kB of archives.
After this operation, 78.8 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian stretch/main amd64 distro-info-data all 0.36 [5810 B]
Get:2 http://deb.debian.org/debian stretch/main amd64 lsb-release all 9.20161125 [27.1 kB]
Fetched 32.9 kB in 0s (274 kB/s)       
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package distro-info-data.
(Reading database ... 30586 files and directories currently installed.)
Preparing to unpack .../distro-info-data_0.36_all.deb ...
Unpacking distro-info-data (0.36) ...
Selecting previously unselected package lsb-release.
Preparing to unpack .../lsb-release_9.20161125_all.deb ...
Unpacking lsb-release (9.20161125) ...
Setting up distro-info-data (0.36) ...
Setting up lsb-release (9.20161125) ...
root@771da843c08d:/# sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
root@771da843c08d:/# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
gpg: no valid OpenPGP data found.

해결된 문제를 보여주는 출력(해결 단계 포함):

root@479753dc1044:/# sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
root@479753dc1044:/# # Remove the DST X3 root certificate, per
root@479753dc1044:/# # https://medium.com/geekculture/will-you-be-impacted-by-letsencrypt-dst-root-ca-x3-expiration-d54a018df257
root@479753dc1044:/# sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
root@479753dc1044:/# update-ca-certificates
Updating certificates in /etc/ssl/certs...
0 added, 1 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@479753dc1044:/# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
OK
root@479753dc1044:/# apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Hit:2 http://security.debian.org/debian-security stretch/updates InRelease
Hit:3 http://deb.debian.org/debian stretch-updates InRelease
Hit:4 http://deb.debian.org/debian stretch Release 
Get:6 http://apt.postgresql.org/pub/repos/apt stretch-pgdg InRelease [81.6 kB]
Get:7 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages [270 kB]
Fetched 352 kB in 1s (220 kB/s)  
Reading package lists... Done

위의 수정 사항을 적용한 후 계속할 수 있습니다(예: 이전 Postgres 클라이언트 설치).

root@479753dc1044:/# apt-get -y install postgresql-client-12
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpq-dev libpq5 pgdg-keyring postgresql-client-common
Suggested packages:
  postgresql-doc-14 postgresql-12 postgresql-doc-12
The following NEW packages will be installed:
  pgdg-keyring postgresql-client-12 postgresql-client-common
The following packages will be upgraded:
  libpq-dev libpq5
2 upgraded, 3 newly installed, 0 to remove and 104 not upgraded.
Need to get 1823 kB of archives.
After this operation, 6032 kB of additional disk space will be used.
Get:1 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 libpq-dev amd64 14.0-1.pgdg90+1 [135 kB]
Get:2 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 libpq5 amd64 14.0-1.pgdg90+1 [169 kB]
Get:3 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 pgdg-keyring all 2018.2 [10.7 kB]
Get:4 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 postgresql-client-common all 231.pgdg90+1 [91.3 kB]
Get:5 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 postgresql-client-12 amd64 12.8-1.pgdg90+1 [1417 kB]
Fetched 1823 kB in 1s (1422 kB/s)              
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 30604 files and directories currently installed.)
Preparing to unpack .../libpq-dev_14.0-1.pgdg90+1_amd64.deb ...
Unpacking libpq-dev (14.0-1.pgdg90+1) over (9.6.17-0+deb9u1) ...
Preparing to unpack .../libpq5_14.0-1.pgdg90+1_amd64.deb ...
Unpacking libpq5:amd64 (14.0-1.pgdg90+1) over (9.6.17-0+deb9u1) ...
Selecting previously unselected package pgdg-keyring.
Preparing to unpack .../pgdg-keyring_2018.2_all.deb ...
Unpacking pgdg-keyring (2018.2) ...
Selecting previously unselected package postgresql-client-common.
Preparing to unpack .../postgresql-client-common_231.pgdg90+1_all.deb ...
Unpacking postgresql-client-common (231.pgdg90+1) ...
Selecting previously unselected package postgresql-client-12.
Preparing to unpack .../postgresql-client-12_12.8-1.pgdg90+1_amd64.deb ...
Unpacking postgresql-client-12 (12.8-1.pgdg90+1) ...
Setting up libpq5:amd64 (14.0-1.pgdg90+1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up pgdg-keyring (2018.2) ...
Removing apt.postgresql.org key from trusted.gpg: OK
Setting up libpq-dev (14.0-1.pgdg90+1) ...
Setting up postgresql-client-common (231.pgdg90+1) ...
Setting up postgresql-client-12 (12.8-1.pgdg90+1) ...
update-alternatives: using /usr/share/postgresql/12/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode

답변3

근본 원인

최근 LSerni가 답변한 대로 루트 인증서가 만료되어 일부 문제가 발생했습니다.

다음은 Letscrypt의 공식 답변입니다.

플랫폼이 Let's Encrypt 인증서를 확인할 수 있는지 여부를 결정하는 주요 요소는 플랫폼이 ISRG의 "ISRG Root X1" 인증서를 신뢰하는지 여부입니다. 2021년 9월 이전에는 일부 플랫폼에서 IdenTrust의 "DST Root CA X3" 인증서를 신뢰했기 때문에 ISRG Root X1이 포함되어 있지 않더라도 인증서를 확인할 수 있었습니다. 2021년 10월부터 ISRG Root X1을 신뢰하는 플랫폼만 Let's Encrypt 인증서를 확인합니다(Android 제외).

자세히 알아보기https://letsencrypt.org/docs/certificate-compatibility/

모든 Debian 버전 >= jessie에는 Letsencrypt를 인식하는 데 필요한 인증서가 포함되어 있어야 합니다. (업데이트됨)

이제 스트레치에는 여기에 나열된 ISRG 루트 X1 인증서가 포함되어야 합니다.

업데이트하려면 다음을 사용해 보세요.

apt update
apt install -y libssl1.0.2 ca-certificates

더 많은 관련 내용을 보려면 여기를 클릭하세요https://serverfault.com/questions/1079199/client-on-debian-9-erroneously-reports-expired-certificate-for-letsencrypt-issue

Postgresql 설치에 대한 참고 사항

에 대한 문서를 참고하시기 바랍니다https://wiki.postgresql.org/wiki/Apt#Quickstart2021년 8월 20일에 'apt-key가 더 이상 사용되지 않습니다'라고 업데이트되었습니다.

다음을 교체할 수도 있습니다.

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

통과:

curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg

또한 스트레치 시 lsb_release를 설치할 필요가 없으며 /etc/os-release 파일을 사용할 수 있습니다. 예를 들면 다음과 같습니다.

OS_CODENAME=$(awk -F= '$1=="VERSION_CODENAME" { print $2 ;}' /etc/os-release)

관련 정보