在作業中,我們有一堆使用自簽名證書的內部服務器。我正在嘗試將這些證書安裝到 Jupyter 筆記本映像中,以便它可以訪問服務器,但由于某種原因它們沒有被找到。這是一個最小的 Dockerfile:
FROM jupyter/datascience-notebook:notebook-6.4.2
USER root
RUN echo 'Acquire::http::proxy "http://proxy.internal.server";' >> /etc/apt/apt.conf.d/99proxy
ENV http_proxy http://proxy.internal.server
ENV https_proxy http://proxy.internal.server
ENV NO_PROXY internal.server
COPY certificates/* /usr/local/share/ca-certificates/
RUN update-ca-certificates
這樣做之后,當我嘗試復制檔案時,例如 with curl -O https://internal.server/file,它失敗并顯示證書無效的訊息。我必須添加-k標志以關閉 SSL 驗證才能成功。
如果我遵循相同的程序,但從 vanilla Ubuntu 映像開始,則沒有問題。(我必須安裝 ca-certificates 和 curl。)
Jupyter 影像是否與證書存盤區有關?安裝證書的正確步驟是什么?
uj5u.com熱心網友回復:
其原因是,Jupyter影像使用暢達和暢達附帶有OpenSSL和它通過自己的CA證書ca-certificates包。你可以在圖片中看到它
python -c "import ssl; print(ssl.get_default_verify_paths())"
# DefaultVerifyPaths(cafile='/opt/conda/ssl/cert.pem', capath=None,
# openssl_cafile_env='SSL_CERT_FILE',
# openssl_cafile='/opt/conda/ssl/cert.pem',
# openssl_capath_env='SSL_CERT_DIR',
# openssl_capath='/opt/conda/ssl/certs')
我沒有使用自定義 CA 證書的理想解決方案。您可以嘗試使用各種環境變數。
export SSL_CERT_DIR=/etc/ssl/certs
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
作為最后的手段,你可以嘗試
- 將證書添加到 conda ca 檔案中
openssl x509 -in /path/to/custom/ca.crt -outform PEM >> $CONDA_PREFIX/ssl/cacert.pem
- 使用指向系統位置的符號鏈接覆寫 conda CA 檔案。
但是,如果ca-certificate更新包,這些修復將中斷。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/338568.html
標籤:码头工人 ssl jupyter-笔记本
