2017-02-10 79 views
10

我不是很習慣java世界,所以我不確定我的問題是在我的Azure設置或java設置。嘗試下面的教程後,我收到以下異常。Java連接到azure事件中心:SunCertPathBuilderException

host.registerEventProcessor(EventProcessor.class, options).get(); 

我做教程的.NET版本的小問題:

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 

例外這條線從樣品中發生。在這種情況下發送和接收作品。任何見解?過去幾天我一直在摸索着,沒有運氣。

+0

你能分享正在使用的conectionString的格式嗎?還要確保你在最新版本。 – Sreeram

+0

@Sreeram Im使用AZURE UI中提供的密鑰 - 長字母數字後跟'=' – Seth

回答

0

原來這是一個愚蠢的網絡問題。 amqp端口僅限白名單。

3

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

  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服務器證書可以添加到本地密鑰庫。請按照GitHub存儲庫的自述文件。

+0

謝謝,看着這個。太多的多任務處理。 – Seth

+0

我跟着這個,它似乎沒有解決它。我確實同意這是cacerts的一個問題,但通過這兩個博客並沒有阻止我的問題。 – Seth

2

下載與瀏覽器證書並將其添加到您的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安裝或者只是添加到所有安裝,給你得到不止一個。

+0

不幸的是,我今天早上想到了它。這是我的網絡上一個封閉的端口。我確實嘗試過這個功能,很有幫助。非常感謝發佈它。 – Seth