I'm using the Google API Client Library for Java to retrieve an access token.
Code:
public static String getAccessToken() throws IOException {
GoogleCredential googleCredential = GoogleCredential
.fromStream(new FileInputStream(PATH_JSON_AUTH02))
.createScoped(Arrays.asList(URL_SCOPE_FCM));
googleCredential.refreshToken();
return googleCredential.getAccessToken();
}
The issue is that the JVM can't find a trusted certificate to make the HTTPS request to Google service. I tried to import all kind of Google's certificate using keytool but still not working.
Exception:
10:03:29,371 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/TesteCertificadoGoogle].[tudo.ApplicationService]] (http--0.0.0.0-8443-2) Servlet.service() for servlet tudo.ApplicationService threw exception: org.jboss.resteasy.spi.UnhandledException: 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
Which certificate should I import?