Google Play Integrity API:PKIX 路径构建失败:....SunCertPathBuilderException:无法找到请求目标的有效证书路径

问题描述 投票:0回答:0

我在尝试在服务器端解码 Play Integrity 令牌时遇到此异常:

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

代码如下:

DecodeIntegrityTokenRequest decodeRequest = new DecodeIntegrityTokenRequest();
decodeRequest.setIntegrityToken(integrityToken);

InputStream stream = Resources.getResource("credentials.json").openStream();
GoogleCredentials credentials = GoogleCredentials.fromStream(stream);
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);
HttpTransport transport = new NetHttpTransport();
GoogleClientRequestInitializer initializer = new PlayIntegrityRequestInitializer();

// <my-project> is the project-id from service account credentials JSON file
PlayIntegrity.Builder playIntegrity = new PlayIntegrity.Builder(
    transport, jsonFactory.getDefaultInstance(),
    requestInitializer).setApplicationName("<my-project>").setGoogleClientRequestInitializer(initializer);
PlayIntegrity play = playIntegrity.build();

DecodeIntegrityTokenResponse response = play.v1().decodeIntegrityToken(appId, decodeRequest).execute();

在 SO 中找到的解决方案建议我需要将证书安装到本地密钥库中,但不确定来自哪个站点的证书。我尝试了

playintegrity.googleapis.com/v1/PACKAGE_NAME
的那个,但没有帮助。

启用 SSL 调试也无济于事。

javax.net.ssl|DEBUG|2C|XNIO-1 task-4|2023-04-24 16:44:26.860 PDT|Utilities.java:73|the previous server name in SNI (type=host_name (0), value=playintegrity.googleapis.com) was replaced with (type=host_name (0), value=playintegrity.googleapis.com)
javax.net.ssl|DEBUG|2C|XNIO-1 task-4|2023-04-24 16:44:26.942 PDT|SSLCipher.java:1850|KeyLimit read side: algorithm = AES/GCM/NOPADDING:KEYUPDATE
countdown value = 137438953472
javax.net.ssl|DEBUG|2C|XNIO-1 task-4|2023-04-24 16:44:26.942 PDT|SSLCipher.java:2004|KeyLimit write side: algorithm = AES/GCM/NOPADDING:KEYUPDATE
countdown value = 137438953472
javax.net.ssl|ERROR|2C|XNIO-1 task-4|2023-04-24 16:44:26.965 PDT|TransportContext.java:312|Fatal (CERTIFICATE_UNKNOWN): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (
"throwable" : {
    sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

知道如何解决这个问题吗?

ssl google-api ssl-certificate google-api-java-client google-play-integrity-api
© www.soinside.com 2019 - 2024. All rights reserved.