尝试使用Gradle将文件上传到Nexus时出现以下错误:
的证书与证书主题的通用名称不匹配:wiki.xyz.corp
细节:
C:\data\Workspaces\httpstest>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 Discussion和Gradle Issues中对此进行了讨论。
可能的解决方法:
gradlew -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true uploadArchives