2017-02-10 31 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