我为一个客户工作,他们的防火墙中有一个自签名的 mitm ssl 解密证书。他们使用 Windows 服务器来运行一些应用程序。我需要为所有包管理软件(如 git、npm、maven、conda、pip)配置证书,以便让这些软件下载内容。
例如,为了使用 git,我必须按照本指南https://mattferderer.com/fix-git-self-signed-certificate-in-certificate-chain-on-windows从 chrome 导出证书,然后修改中的.gitconfig文件C:\Users\X999999\.gitconfig。由于我还需要将 jenkins 作为 SYSTEM 服务运行,因此我还需要修改 .gitconfigin C:\Windows\System32\config\systemprofile\.gitconfig. 修改后的内容是这样的:
[http]
sslCAInfo = C:\\sslcert\\2020-ssl-decrypt.cer
另一个例子,为了使用 npm,我必须遵循这个指南How to fix SSL certificate error when running Npm on Windows? 修改.npmrcinC:\Users\X999999\.npmrc和 inC:\Windows\System32\config\systemprofile\.npmrc如下:
cafile=C:\sslcert\2020-ssl-decrypt.cer
用了几天效果很好。问题是今天我发现我不能使用 npm!它显示了这个错误:
npm install coffee-script
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/coffee-script failed, reason: unable to get local issuer certificate
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\X999999\AppData\Roaming\npm-cache\_logs\2020-12-10T05_59_28_281Z-debug.log
然后尝试使用 chrome 打开https://registry.npmjs.org/并检查证书。. 中似乎不再有 2020-ssl-decrypt Certification Path。然后我在文件中删除了这一行, npm 再次工作。因此,防火墙今天似乎已禁用站点 registry.npmjs.org 的 ssl 证书。cafile=C:\sslcert\2020-ssl-decrypt.cer.npmrc
我还记得几个月前,我也不需要配置证书让git访问github.com。因此,防火墙的行为似乎是有线的,或者它的配置正在来回变化。
那么有没有办法(脚本或其他东西)让这些包管理软件(git、npm、maven、conda、pip)自动检测站点是否需要证书并使用证书?我知道设置为 git 或 npm 禁用 SSL 证书验证可以避免这些问题,但它并不安全。
另外,我注意到2020-ssl-decrypt.cer从 chrome 导出的仅在 2020 年 2 月至 2021 年 2 月期间有效。那么是否有任何脚本或方法可以在证书过期后自动导出证书?