Java 连接到 azure 事件中心:SunCertPathBuilderException
Java Connecting to azure event hub: SunCertPathBuilderException
我不太习惯 java 世界,所以我不确定我的问题是出在我的 Azure 设置上,还是 java 设置上。在尝试下面的教程后,我收到以下异常。
https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-java-get-started-receive-eph
Failure while registering:
com.microsoft.azure.eventprocessorhost.EPHConfigurationException:
Encountered error while fetching the list of EventHub PartitionIds:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
示例中的这一行发生异常:
host.registerEventProcessor(EventProcessor.class, options).get();
我完成了本教程的 .NET 版本,问题不大。在这种情况下发送和接收工作。有什么见解吗?这几天一直在摸索,没有运气。
我搜索了你的问题,找到了一些有用的博客,可以帮助解决问题,请参考下面的博客。
- https://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
- http://nodsw.com/blog/leeland/2006/12/06-no-more-unable-find-valid-certification-path-requested-target
以上博客都使用了工具InstallCert
来服务器证书,可以添加到本地密钥库。请遵循 GitHub 存储库的自述文件。
使用浏览器下载证书并将其添加到您的 Java 密钥库,如下所示:
C:\java\jdk1.8.0_60\jre\lib\security>C:\java\jdk1.8.0_60\jre\bin\keytool.exe -import -alias alias -file C:\path\to\file.crt -keystore C:\java\jdk1.8.0_60\jre\lib\security>cacerts -storepass changeit
您需要确保将证书添加到正确的 Java 安装或仅添加到所有安装,前提是您有多个安装。
原来这是一个愚蠢的网络问题。 amqp 端口仅是白名单。
正在添加证书:
keytool -keystore C:\Program" "Files\Java\jre1.8.0_171\lib\security\cacerts -import -alias aliasName
-file C:\Users\cg\Downloads\springio.cer -storepass changeit
检查已安装的证书:
keytool -keystore C:\Program" "Files\Java\jre1.8.0_171/lib/security/cacerts -storepass changeit -list
我不太习惯 java 世界,所以我不确定我的问题是出在我的 Azure 设置上,还是 java 设置上。在尝试下面的教程后,我收到以下异常。
https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-java-get-started-receive-eph
Failure while registering:
com.microsoft.azure.eventprocessorhost.EPHConfigurationException:
Encountered error while fetching the list of EventHub PartitionIds:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
示例中的这一行发生异常:
host.registerEventProcessor(EventProcessor.class, options).get();
我完成了本教程的 .NET 版本,问题不大。在这种情况下发送和接收工作。有什么见解吗?这几天一直在摸索,没有运气。
我搜索了你的问题,找到了一些有用的博客,可以帮助解决问题,请参考下面的博客。
- https://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
- http://nodsw.com/blog/leeland/2006/12/06-no-more-unable-find-valid-certification-path-requested-target
以上博客都使用了工具InstallCert
来服务器证书,可以添加到本地密钥库。请遵循 GitHub 存储库的自述文件。
使用浏览器下载证书并将其添加到您的 Java 密钥库,如下所示:
C:\java\jdk1.8.0_60\jre\lib\security>C:\java\jdk1.8.0_60\jre\bin\keytool.exe -import -alias alias -file C:\path\to\file.crt -keystore C:\java\jdk1.8.0_60\jre\lib\security>cacerts -storepass changeit
您需要确保将证书添加到正确的 Java 安装或仅添加到所有安装,前提是您有多个安装。
原来这是一个愚蠢的网络问题。 amqp 端口仅是白名单。
正在添加证书:
keytool -keystore C:\Program" "Files\Java\jre1.8.0_171\lib\security\cacerts -import -alias aliasName
-file C:\Users\cg\Downloads\springio.cer -storepass changeit
检查已安装的证书:
keytool -keystore C:\Program" "Files\Java\jre1.8.0_171/lib/security/cacerts -storepass changeit -list