1

I am trying to connect with azure using adal4j@1.6.4 library for java to get the access token. My application is behind a corporate proxy so I have to set the proxy to connect with azure.

Following is the snippet of code

String url = "https://login.microsoftonline.com/tenant_id/oauth2/authorize";
authContext = new AuthenticationContext(url,false, service);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyhostname", 8080));
authContext.setProxy(proxy);
ClientCredential clientCred = new ClientCredential(XXXX, xxxx);
Future future = authContext.acquireToken(clientCred,null);
authResult = future.get();

When I use proxy to connect, I am getting certificate error.

0:53:23.561 [pool-1-thread-1] ERROR com.microsoft.aad.adal4j.AuthenticationContext - [Correlation ID: xxxxxxxxxxxxxxxxxxxxxxx] Execution of class com.microsoft.aad.adal4j.AcquireTokenCallable failed.
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
Sohail Ashraf
  • 10,078
  • 2
  • 26
  • 42
  • Did you check these two questions which talk about a resolution for a similar issue? https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ?noredirect=1&lq=1 , https://www.techsupper.com/2017/11/javax-net-ssl-sslhandshakeexception-sun-security-validator-validatorexception-pkix-path-building-failed.html – Nishant Apr 28 '20 at 15:30

0 Answers0