簡體   English   中英

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 版本的教程,沒有什么問題。 在這種情況下,發送和接收工作。 有什么見解嗎? 最近幾天我一直在摸索,沒有運氣。

我搜索了您的問題並找到了一些可以幫助解決問題的有用博客,請參閱下面的博客。

  1. https://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
  2. http://nodsw.com/blog/leeland/2006/12/06-no-more-unable-find-valid-certification-path-requested-target

以上博客都使用了InstallCert工具來服務器證書,可以添加到本地keystore。 請按照 GitHub 存儲庫的 README 進行操作。

使用瀏覽器下載證書並將其添加到 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM