10

I'm not very used to java world, so I'm not sure if my problem is on my Azure set up, or java set up. I am getting the following exception after attempting the tutorial below.

https://learn.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

The exception occurs during this line from the sample:

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

I did the .NET version of the tutorial with little problem. Sending and receiving works in that case. Any insights? I've been fumbling around with no luck the last few days.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
Seth
  • 954
  • 1
  • 15
  • 42

4 Answers4

3

I searched for your issue and find some helpful blogs which can help solving the issue, please refer to the blogs below.

  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

The above blogs all used the tool InstallCert to server certificate that can be added to local keystore. Please follow the README of the GitHub repository.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Thanks, looking into this. Too much multitasking. – Seth Feb 16 '17 at 20:28
  • I followed this, and it doesn't seem to have solved it. I actually do agree that this is an issue with cacerts, but going through both blogs didnt unjam my problem. – Seth Feb 16 '17 at 21:54
2

Download the certificate with your browser and add it to your Java keystore like this:

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

You need to make sure to add the cert to the correct Java installation or just add to all installations, given you got more than one.

JSamir
  • 1,057
  • 1
  • 10
  • 20
  • Unfortunately, i figured it out this morning. It was a closed port on my network. I did try this function and is helpful. Thanks a lot for posting it. – Seth Feb 23 '17 at 21:30
0

Turns out it was a stupid network problem. The amqp port is whitelist only.

Seth
  • 954
  • 1
  • 15
  • 42
0

Adding certificate:

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

To check installed certificates:

keytool -keystore C:\Program" "Files\Java\jre1.8.0_171/lib/security/cacerts -storepass changeit -list
Chandramouli
  • 552
  • 4
  • 6