Sonatype Nexus上传失败,nexus.xyz.corp的证书与证书主题的通用名称不匹配:wiki.xyz.corp



尝试使用 Gradle 将文件上传到 Nexus 时出现以下错误:

的证书与

证书使用者的公用名不匹配:wiki.xyz.corp

详:

C:dataWorkspaceshttpstest>gradlew uploadArchives
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar SKIPPED
:uploadArchives
Could not transfer artifact com.xyz:httpstest:jar:1.0.0 from/to remo
te (https://nexus.xyz.corp/nexus/content/repositories/1st-rel/): Cer
tificate for <nexus.xyz.corp> doesn't match common name of the certi
ficate subject: wiki.xyz.corp
Could not transfer artifact com.xyz:httpstest:pom:1.0.0 from/to remo
te (https://nexus.xyz.corp/nexus/content/repositories/1st-rel/): Cer
tificate for <nexus.xyz.corp> doesn't match common name of the certi
ficate subject: wiki.xyz.corp
:uploadArchives FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':uploadArchives'.
> Could not publish configuration 'archives'
   > Failed to deploy artifacts: Could not transfer artifact com.xyz
:httpstest:jar:1.0.0 from/to remote (https://nexus.xyz.corp/nexus/co
ntent/repositories/1st-rel/): Certificate for <nexus.xyz.corp> doesn
't match common name of the certificate subject: wiki.xyz.corp
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 5.511 secs

通过HTTPS下载工作正常,但上传则不然。nexus.xyz.corp的证书具有正确的通用名称,而不是错误消息所暗示的wiki.xyz.corp。但是,wiki.xyz.corp是在同一服务器上运行的不同站点。

这里有什么问题?

当使用SNI共享不同的域(wiki.xyz.corp和nexus.xyz.corp)时,就会发生这种情况。它至少出现在 Gradle 2.5 - Gradle 2.13 版本中。原因是 Gradle 在不支持 SNI 的版本中使用 Maven Wagon 库。在这种情况下,Web 服务器将返回默认证书。看起来,wiki.xyz.corp被定义为默认证书。

这在 Gradle 讨论

和 Gradle Issues中进行了讨论。

可能的解决方法:

  • 将nexus.xyz.corp定义为默认证书,但要注意其他站点上的问题
  • 将Maven
  • Wagon替换为Maven Publish,但这目前处于测试阶段。请参阅Maven Publish。
  • 尝试在没有 SNI 的情况下配置系统
  • 以禁用主机检查的方式启动 Gradle(这是一个安全漏洞!

gradlew -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true uploadArchives

最新更新