0

I'm working on a library that is meant to be integrated in other applications. I have to communicate with a https server, and I'm using apache commons HttpClient 3.1. I have my own keystore and need to register a Protocol via: Protocol.registerProtocol. I was wondering if there was a way to register this for my specific instance of the client rather than statically - this way I don't mess up any other instances and nobody messes me up.

I saw something where I can get the clients HostConfiguration and call setHost, with a protocol, but it doesn't appear to work properly. I'm registering it like:

HostConfiguration config = client.getHostConfiguration();
config.setHost(remoteUrl.getHost(), remoteUrl.getPort(), new Protocol("https", new MyProtocolSocketFactory(), 443));

but when trying to make a connection, the SSL handshake fails, while it works when using Protocol.registerProtocol with the same parameters. The failure is the standard:

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

skaffman
  • 398,947
  • 96
  • 818
  • 769
NG.
  • 22,560
  • 5
  • 55
  • 61
  • possible duplicate of [Unable to find valid certification path to requested target - error even after cert imported](http://stackoverflow.com/questions/9210514/unable-to-find-valid-certification-path-to-requested-target-error-even-after-c) – László Papp Jul 13 '14 at 07:30

1 Answers1

-2

Upgrade to HttpComponents 4 and leave client 3.x alone.

NG.
  • 22,560
  • 5
  • 55
  • 61