Ubuntu 20.04にカスタムCA証明書を追加すると正常に動作しますが、Debianでは失敗します。

Ubuntu 20.04にカスタムCA証明書を追加すると正常に動作しますが、Debianでは失敗します。

Ubuntu(20.04)に新しいCA証明書を追加するプロセスを進めましたが、両方の環境のDebian(10)で同じ手順が機能しません。カスタムCA証明書をダウンロードしました(about:certificatefirefoxページから証明書をインポートすると、信頼できる証明書は機能しません)。サイト)をPEMとして保存し、opensslを使用してCRT形式に変換してからupdate-ca-certificates

次のステップは次のとおりですDockerfile

FROM ubuntu:20.04
RUN apt update &&  DEBIAN_FRONTEND=noninteractive apt install -y curl openssl ca-certificates
COPY src/main/docker/nexus-custom-ca-chain.pem /root/
RUN openssl x509 -in /root/nexus-custom-ca-chain.pem -inform PEM -out /usr/local/share/ca-certificates/custom-root-ca.crt
RUN update-ca-certificates
RUN curl https://nexus-using-custom-cert.custom.org

このDockerfileのビルド

docker build . --no-cache                                                                                         

出力されます:

Step 1/6 : FROM ubuntu:20.04
 ---> 9140108b62dc
Step 2/6 : RUN apt update &&  DEBIAN_FRONTEND=noninteractive apt install -y curl openssl ca-certificates
 ---> Running in 2fd506a9b619
[install stuff]
Processing triggers for ca-certificates (20190110ubuntu1.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Removing intermediate container 2fd506a9b619
 ---> 57c01aa6180d
Step 3/6 : COPY src/main/docker/nexus-custom-ca-chain.pem /root/
 ---> e0aa6a44ced1
Step 4/6 : RUN openssl x509 -in /root/nexus-custom-ca-chain.pem -inform PEM -out /usr/local/share/ca-certificates/custom-root-ca.crt
 ---> Running in 70746b6e16fe
Removing intermediate container 70746b6e16fe
 ---> de9c98488bde
Step 5/6 : RUN update-ca-certificates
 ---> Running in 1137779ed67f
Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Removing intermediate container 1137779ed67f
 ---> c834167a52a3
Step 6/6 : RUN curl https://nexus-using-custom-cert.custom.org
 ---> Running in a8dc2aa55993
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<html>

<body> stuff
</body>
</html>
100   470  100   470    0     0   1492      0 --:--:-- --:--:-- --:--:--  1487
Removing intermediate container a8dc2aa55993
 ---> 809e4e5b6ac1
Successfully built 809e4e5b6ac1

ただし、代わりに使用する場合debian:10(他の変更はありませんDockerfile):

FROM debian:10

次にDockerイメージを再構築します。

このDockerfileのビルド

docker build . --no-cache                                                                                         

出力されます:

Step 1/6 : FROM debian:10
 ---> f6dcff9b59af
Step 2/6 : RUN apt update &&  DEBIAN_FRONTEND=noninteractive apt install -y curl openssl ca-certificates
 ---> Running in 15d0c69448ed
[install stuff]
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for ca-certificates (20200601~deb10u1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Removing intermediate container 15d0c69448ed
 ---> 4bcfe8b5074b
Step 3/6 : COPY src/main/docker/nexus-custom-ca-chain.pem /root/
 ---> fa53734a536a
Step 4/6 : RUN openssl x509 -in /root/nexus-custom-ca-chain.pem -inform PEM -out /usr/local/share/ca-certificates/custom-root-ca.crt
 ---> Running in b86813e50a77
Removing intermediate container b86813e50a77
 ---> 0b0e6aa67d7d
Step 5/6 : RUN update-ca-certificates
 ---> Running in c18625c31424
Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Removing intermediate container c18625c31424
 ---> 559636874009
Step 6/6 : RUN curl https://nexus-using-custom-cert.custom.org
 ---> Running in fcd2e16441fd
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
The command '/bin/sh -c curl https://nexus-using-custom-cert.custom.org' returned a non-zero code: 60

では、カスタムCA証明書を追加するにはどうすればよいですかDebian 10? Debianupdate-ca-certificatesドキュメントはUbuntuドキュメントと非常によく似ています。何が間違っていますか?

よろしくお願いします!

ベストアンサー1

私の同僚@BrettDGのおかげで、Debianでも動作させることができました。

全長DR:信頼チェーンのすべての証明書を個別に含める必要があります。 Ubuntuは中間証明書のみを満たし、Debianはチェーン全体を必要とします。

私がリンクしたいウェブサイトには、次の信頼チェーンがあります。

MyOrgRootCA
|-> MyOrgIntermediateCA
    |-> Website

nexus-custom-ca-chain.pem私のPEMファイルに完全なチェーンがあると思われる場合は、次のように実行します。

openssl x509 -in /usr/local/share/ca-certificates/nexus-custom-ca-chain.pem -noout -text

結局、そのチェーンにはサイト証明書と仲介証明書のみがあると表示されます。 したがって、ルート証明書が失われました。

また、1つのファイルに複数の証明書を持つことが良い考えであるかどうかはわかりません。個別に独自のファイルに分割してみてください。

DebianとUbuntu用のDockerfileは次のとおりです。

# FROM ubuntu:20:04
FROM debian:10
RUN apt update &&  DEBIAN_FRONTEND=noninteractive apt install -y curl openssl ca-certificates
COPY root.pem /usr/local/share/ca-certificates/root.pem
COPY intermediate.pem /usr/local/share/ca-certificates/intermediate.pem
RUN chmod 644 /usr/local/share/ca-certificates/root.pem /usr/local/share/ca-certificates/intermediate.pem
RUN update-ca-certificates
RUN curl https://nexus-using-custom-cert.custom.org

学んだ知識:信頼チェーンを検証し、チェーンの各証明書を提供します。

チェーン内の各証明書から出力を実行し、openssl x509 -noout次を見つけます。

MyOrgRootCA
Issuer:  C = CA, ST = Quebec, L = Montreal, O = Org, OU = tools, CN = Org ROOT CA
Subject: C = CA, ST = Quebec, L = Montreal, O = Org, OU = tools, CN = Org ROOT CA
MyOrgIntermediateCA
Issuer:  C = CA, ST = Quebec, L = Montreal, O = Org, OU = tools, CN = Org ROOT CA
Subject: C = CA, ST = Quebec, L = Montreal, O = Org, OU = tools, CN = Intermediate ROOT CA

そこで私たちのcurl -vウェブサイトに以下が表示されている場合:

issuer: C = CA, ST = Quebec, L = Montreal, O = Org, OU = tools, CN = Intermediate ROOT CA

私たちは、中間証明書とルート証明書を提供するのが最善であることを知っています。

便利なコマンドライン

証明書を詳しく確認してください。

openssl x509 -in mycert.crt -noout -text

バイナリ(DER)形式からx509 PEMに変換(必要な場合update-ca-certificates

openssl x509 -in mycert.crt  -inform der -outform PEM -out mycert.crt

テキスト(PEM)形式からバイナリに変換(Java Keytoolのニーズに応じて)

openssl x509 -in mycert.pem -outform der -out mycert.der

おすすめ記事