简体   繁体   English

Maven + Nexus + Jenkins SSL证书错误

[英]Maven+Nexus+Jenkins SSL certificate error

I have installed certificate to nexus. 我已将证书安装到nexus。 When i start jenkins builder im getting an error: 当我启动jenkins builder时,出现错误:

[ERROR] Failed to execute goal on project wf-base: Could not resolve dependencies for project 1.0.0o-SNAPSHOT: Failed to collect dependencies at 1.0.0o-SNAPSHOT: 

Failed to read artifact descriptor for 1.0.0o-SNAPSHOT: Could not transfer artifact 1.0.0o-SNAPSHOT from/to Nexus (https://nexus.repository.link): 

sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

Looks like you're missing a certificate in the chain so your certificate isn't trusted,if it's a self signed certificate you'll need to add it as a root certificate. 好像您在链中缺少证书,因此您的证书不受信任;如果它是自签名证书,则需要将其添加为根证书。 If the certificate was issued by a CA you'll need to download the missing certificate(s) in the chain and install them. 如果证书是由CA颁发的,则需要下载链中缺少的证书并进行安装。

Here are some options for those of you (like me) who stumbled on this issue. 对于那些偶然发现此问题的人(如我),这里有一些选择。

1. Import CA in java trust store 1.在Java信任库中导入CA

The first option is to import your certificate authority(ies) in your jre cacert file using keytool . 第一种选择是使用keytool证书颁发机构导入jre cacert文件。

This option, although it seems to be the most natural, has one drawbacks: this implies to have write access to the JRE / JDK folders, which is not always the case. 此选项虽然看起来是最自然的,但它有一个缺点:这意味着具有对JRE / JDK文件夹的写访问权限,但并非总是如此。

2. Pass trust store as a param to the JVM in Maven using Jenkins 2.使用Jenkins将信任库作为参数传递给Maven中的JVM

Here is the trick: maven passes a set of parameters to the jvm before it runs. 这是窍门: maven在运行之前将一组参数传递给jvm These parameters are wrapped in a variable called MAVEN_OPTS wihch are initialized in the mvn script. 这些参数包装在一个名为MAVEN_OPTS的变量中,该变量在mvn脚本中初始化。

The way to go when using Jenkins is to create an environment variable in your slave or your job, call it MAVEN_OPTS and give it the JVM option: 使用Jenkins的方法是在您的奴隶或工作中创建一个环境变量,将其MAVEN_OPTSMAVEN_OPTS提供JVM选项:

MAVEN_OPTS
-Djavax.net.ssl.trustStore=your_custom_cert_file

As always, there are many other possibilities but these two are the cleanest ones. 与往常一样,还有许多其他可能性,但这两种是最干净的可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM