scala sbt 和企业代理 - SunCertPathBuilderException
当我尝试使用 SBT 时,某些文件无法下载并出现以下错误:
When I try to use SBT some files cannot be downloaded with the following error:
服务器访问错误:sun.security.validator.ValidatorException: PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.0.0-M4/sbt-1.0.0-M4.jar
Server access Error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.0.0-M4/sbt-1.0.0-M4.jar
我遵循了有关 Stack Overflow 的一些建议,并使用 java keytool 导入了公司代理 SSL 证书,如下所述:网络服务代理中的 SSL 证书问题
I have followed some advice on Stack Overflow and imported the corporate proxy SSL certificate with the java keytool as described in: SSL certificate problem in a web service proxy
它似乎不影响 SBT 工具.它看起来在不同的密钥库中吗?有什么想法吗?
It does not seems to affect the SBT tool. Does it look in a different keystore? Any ideas?
如果我将 URL 粘贴到文件下载的浏览器上.
If I paste the URL on the browser the file downloads.
仅运行已安装的 SBT 工具时出现此错误.当我尝试在 IntelliJ Idea 上创建一个 SBT 项目并对其进行更新时,它给了我使用不同 URL 的相同错误.尝试使用 lightbend 激活器时也是如此.
I get this error when simply running the SBT tool I have installed. When I try to create a SBT project on IntelliJ Idea and update it, it gives me the same error with different URLs. Same thing when trying to use the lightbend activator.
推荐答案
所以当你在代理后面时会发生这种情况,我们需要将代理服务器证书添加到 java 信任库中
So this happens when you are behind a proxy and we need the proxy server certificate to be added to the java truststore
cp $JAVA_HOME/jre/lib/security/cacerts <some accessible dir>/
# Get the certificate of the proxy server and store it in a file-proxy.pem
keytool -keystore cacerts -import -file proxy.pem -alias my_proxy
# Now we can invoke sbt with following config
sbt "-Djavax.net.ssl.trustStore=/path/to/included/proxycert/cacerts" compile
相关文章