微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Amadeus:httpsUrlConnection异常SunCertPathBuilderException

如何解决Amadeus:httpsUrlConnection异常SunCertPathBuilderException

当我尝试调用获取授权令牌时,出现此异常-

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)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1478)

这是我们的代码-

URL urlAuthToken = new URL("https://test.api.amadeus.com/v1/security/oauth2/token");
httpsConAuthToken = (HttpsURLConnection) urlAuthToken.openConnection();
httpsConAuthToken.setRequestMethod("POST");
httpsConAuthToken.setRequestProperty("Cache-Control","no-cache");
httpsConAuthToken.setRequestProperty(
    "Content-Type","application/x-www-form-urlencoded");

httpsConAuthToken.setDoInput(true);
httpsConAuthToken.setDoOutput(true);

String paramsToPassAuthToken = "grant_type=client_credentials&client_id={api key}&client_secret={secret}";
DataOutputStream wr = new DataOutputStream (
                httpsConAuthToken.getoutputStream ());
wr.writeBytes(paramsToPassAuthToken);
wr.flush();
wr.close();

请让我知道如何解决此问题。感谢您的帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。