我如何强制 apt-get 或 apt 仅使用 https 连接

我如何强制 apt-get 或 apt 仅使用 https 连接

我仅使用 https 在网络上运行 mongo db docker 容器。容器使用 apt-get 来安装软件包。由于网络仅允许 https 连接,因此 apt-get 不适用于我。安装 apt-transport-https 后,我尝试在 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中使用 https 更改 http。但对我来说没有任何作用。这是我用 https 替换 https 后的 /etc/apt/sources.list

deb https://deb.debian.org/debian jessie main
deb https://security.debian.org/debian-security jessie/updates main
deb https://deb.debian.org/debian jessie-updates main

/etc/apt/sources.list.d 中的 mongodb-org.list 文件看起来像

deb https://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 main

完成所有这些 apt-get update 显示后

Get:1 https://repo.mongodb.org jessie/mongodb-org/3.2 InRelease [384 B]
Ign https://repo.mongodb.org jessie/mongodb-org/3.2 InRelease
Get:2 https://repo.mongodb.org jessie/mongodb-org/3.2 Release.gpg [801 B]
Hit https://repo.mongodb.org jessie/mongodb-org/3.2 Release
Get:3 https://deb.debian.org jessie InRelease [309 B]
Ign https://deb.debian.org jessie InRelease
Hit https://deb.debian.org jessie-updates InRelease
Ign https://security.debian.org jessie/updates InRelease
Ign https://repo.mongodb.org jessie/mongodb-org/3.2 Release
Get:4 https://repo.mongodb.org jessie/mongodb-org/3.2/main amd64 Packages [10.6 kB]
Hit https://deb.debian.org jessie Release.gpg
Ign https://security.debian.org jessie/updates Release.gpg
Ign https://security.debian.org jessie/updates Release
Get:5 https://deb.debian.org jessie-updates/main amd64 Packages [337 B]
Err https://security.debian.org jessie/updates/main amd64 Packages

Hit https://deb.debian.org jessie Release
Err https://security.debian.org jessie/updates/main amd64 Packages

Err https://security.debian.org jessie/updates/main amd64 Packages

Get:6 https://deb.debian.org jessie/main amd64 Packages [329 B]
Err https://security.debian.org jessie/updates/main amd64 Packages

Err https://security.debian.org jessie/updates/main amd64 Packages
  server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
Fetched 9110 kB in 8s (1096 kB/s)
W: GPG error: https://repo.mongodb.org jessie/mongodb-org/3.2 Release: The following signatures were invalid: KEYEXPIRED 1570654450
W: Size of file /var/lib/apt/lists/partial/deb.debian.org_debian_dists_jessie-updates_main_binary-amd64_Packages.gz is not what the server reported 20 337
W: Failed to fetch https://security.debian.org/debian-security/dists/jessie/updates/main/binary-amd64/Packages  server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

E: Some index files failed to download. They have been ignored, or old ones used instead.

答案1

无法从 https 连接检索安全更新,解释如下德比安

目前,主机security.debian.org在 HTTPS 上没有可公开验证的 SSL 证书,因此目前无法与 HTTPS 一起使用。

您可以/etc/apt/sources.list按如下方式编辑您的:

deb https://deb.debian.org/debian jessie main
deb http://security.debian.org/debian-security jessie/updates main
deb https://deb.debian.org/debian jessie-updates main

要解决 MongoDB 的 gpg 密钥错误,您应该更新 gpg 密钥,请参阅我导入包管理系统使用的公钥

wget -qO - https://www.mongodb.org/static/pgp/server-3.2.asc | sudo apt-key add -

答案2

如果您使用的是 Debian,请更新您的/etc/apt/sources.list条目以指向官方 https 镜像重定向器:

deb https://deb.debian.org/debian/ <dist> <suite>
deb-src https://deb.debian.org/debian/ <dist> <suite>

例如对于 Debian 不稳定版:

deb https://deb.debian.org/debian/ unstable main
deb-src https://deb.debian.org/debian/ unstable main

您可以参考这些更多信息 -

指定错误

相关内容