Java Openshift部署F8:无法访问群集以检测模式:sun.security.validator.ValidatorException

Java Openshift部署F8:无法访问群集以检测模式:sun.security.validator.ValidatorException,java,kubernetes,ssl-certificate,openshift,fabric8,Java,Kubernetes,Ssl Certificate,Openshift,Fabric8,我正在使用fabric8 maven deploy部署示例springboot应用程序。生成失败,出现SSLHandshakeException F8: Cannot access cluster for detecting mode: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: u

我正在使用fabric8 maven deploy部署示例springboot应用程序。生成失败,出现SSLHandshakeException

F8: Cannot access cluster for detecting mode: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Failed to execute goal io.fabric8:fabric8-maven-plugin:3.1.80.redhat-000010:build (default) on project fuse-camel-sb-rest: Execution default of goal io.fabric8:fabric8-maven-plugin:3.1.80.redhat-000010:build failed: An error has occurred. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:fabric8-maven-plugin:3.1.80.redhat-000010:build (default) on project fuse-camel-sb-rest: Execution default of goal io.fabric8:fabric8-maven-plugin:3.1.80.redhat-000010:build failed: An error has occurred.
因此,我从Openshift webconsole下载了公共证书,并使用

C:\...\jdk.\bin>keytool -import -alias rootcert -file C:\sample\RootCert.cer -keystore cacerts
并得到一条消息,表明它已成功添加到密钥库,list命令显示已添加的证书

    C:\...\jdk.\bin>keytool -list -keystore cacerts
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN

Your keystore contains 2 entries

rootcert, May 18, 2018, trustedCertEntry,
Certificate fingerprint (SHA1): XX:XX:XX:..........
但是mvn:fabric8部署构建仍然失败,出现了相同的异常


有人能解释一下这个问题吗?我遗漏了什么吗?

将证书添加到$JAVAHOME/jre/lib/security中的“cacerts”解决了这个问题

杰克的解决方案在Windows上运行良好。当我在openshift webconsole上时,我从webrowser导出了证书。然后我在$JAVAHOME/jre/lib/security中将cert添加到cacerts中:
keytool-import-alias my.alias-C:\sample\RootCert.cer-keystore-cacerts文件在MacOS上的工作如下:

要安装的证书是在浏览器URL栏上找到的证书
在Firefox上(至少)单击URL左侧的挂锁,然后继续连接>/更多信息/查看证书/详细信息,最后导出…允许您在本地保存证书

在命令行上,确定JRE maven正在使用的是:

$ mvn --version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T19:33:14+01:00)
Maven home: /Users/.../apache-maven-3.5.4
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
您可能需要是“root”才能更新cacerts文件

$ sudo keytool -import -alias my-openshift-clustername -file /Users/.../downloads/my-cluster-cert.crt -keystore $JAVA_HOME/jre/lib/security/cacerts
Password: {your password for sudo}
Enter keystore password: {JRE cacerts password, default is changeit}
... keytool prints certificate details...
Trust this certificate? [no]:  yes
Certificate was added to keystore
验证证书确实已成功添加:

$ keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts
Enter keystore password: changeit
Keystore type: JKS
Keystore provider: SUN

Your keystore contains 106 entries

...other entries, in no particular order...
my-openshift-clustername, 25-Feb-2019, trustedCertEntry,
Certificate fingerprint (SHA1): F4:17:3B:D8:E1:4E:0F:AD:16:D3:FF:0F:22:73:40:AE:A2:67:B2:AB
...other entries...

我在Windows上解决了添加Openshift证书的问题,其中包含以下内容:

keytool -import -trustcacerts -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit -alias Root -import -file openshift.der

openshift.der在BASE64中。

您添加了哪个证书?openshift证书还是docker注册表证书?@jordi,openshift证书。登录到Openshift控制台并下载它