我有一个 Docker 构建脚本,它在本地机器上运行良好,但在我的构建服务器上失败并出现错误“无法创建 SSL/TLS 安全通道”。尝试使用 TLS 1.2 从资源中检索存档时会发生这种情况。
从本地计算机上的命令行下载工作正常;问题出在 Docker Windows 镜像中。
为了解决这个问题,我在 Dockerfile 中添加了以下内容:
- 运行 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
- 运行“Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord;”
无论我做什么,当我运行 RUN [Net.ServicePointManager]::SecurityProtocol;在我的 Dockerfile 中,我被告知唯一可用的协议(protocol)是 Ssl3 和 Tls,而不是 Tls12。
感谢您的任何建议。
最佳答案
有点晚了,但是 RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;当 RUN 命令完成时丢失。您需要将其包含在同一个 RUN 中,例如:
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/v$env:NUGET_VERSION/nuget.exe" -UseBasicParsing -OutFile "$env:ProgramFiles\NuGet\nuget.exe"
关于docker - 无法在 Docker 构建中创建 SSL/TLS 安全通道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56854238/