0

I am building an application in Spring. The application is supposed to make some REST calls to Starling's sandbox/developer exposed API.

I am trying to make a call to Starlings api but since it's under HTTPS, i get the following:

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

Upon reading Starlings documentation, it does provide the certificate I need along with the following instructions:

You will need to embed the certificate during development and associate it with our domain. Then, during the SSL challenge with us your application should validate our identity with the certificates. Libraries to do this are available for almost all languages and platforms, for example TrustKit on iOS and okhttp for Java.

I am using okhttp to make the calls but I can't figure out how to make okhttp accept the certificate. I did come across this question and tried to implement it but wasn't sure what to put for the value of the hostname. In the answer it has: .add(hostname, "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")... is the the sha56/AAAAA supposed to be the contents of the certificate?

EDIT: I have tried placing the contents of the certificate within the "sha56/AAA" area and got the following:

java.lang.IllegalArgumentException: pins must start with 'sha256/' or 'sha1/': MIIGQDCCBSigAwIBAgIMA/4EOE5OkRQN7SNQMA0GCSqGSIb3DQEBCwUAMFAxCzAJ

so I'm guessing I'll need to somehow generate the the sha using the cert?

bootlover123
  • 111
  • 1
  • 8
  • This link could help you : https://stackoverflow.com/questions/25509296/trusting-all-certificates-with-okhttp – Harry Coder Oct 20 '21 at 00:10
  • Still same issue. I have even followed their example on GitHub: https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/CustomTrust.java but still same issue occuring – bootlover123 Oct 20 '21 at 02:02

0 Answers0