使用 Java SDK 查询 Kusto 时如何避免“PKIX 路径构建失败”错误?

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

我正在使用 Java SDK for Kusto(Azure 数据资源管理器)。

<groupId>com.microsoft.azure.kusto</groupId>
<artifactId>kusto-data</artifactId>
<version>5.0.3</version>

我正在通过 aad 应用程序注册连接到 kusto,当我尝试执行查询时,我收到此错误:

com.microsoft.azure.kusto.data.exceptions.DataServiceException: IOException when trying to retrieve cluster metadata:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.microsoft.azure.kusto.data.auth.CloudInfo.lambda$retrieveCloudInfoForCluster$0(CloudInfo.java:108)
    at com.microsoft.azure.kusto.data.ExponentialRetry.execute(ExponentialRetry.java:39)
    at com.microsoft.azure.kusto.data.auth.CloudInfo.retrieveCloudInfoForCluster(CloudInfo.java:100)
    at com.microsoft.azure.kusto.data.auth.CloudDependentTokenProviderBase.lambda$initialize$0(CloudDependentTokenProviderBase.java:38)
    at com.microsoft.azure.kusto.data.instrumentation.MonitoredActivity.invoke(MonitoredActivity.java:33)
    at com.microsoft.azure.kusto.data.auth.CloudDependentTokenProviderBase.initialize(CloudDependentTokenProviderBase.java:37)
    at com.microsoft.azure.kusto.data.auth.TokenProviderBase.acquireAccessToken(TokenProviderBase.java:30)
    at com.microsoft.azure.kusto.data.ClientImpl.generateIngestAndCommandHeaders(ClientImpl.java:405)
    at com.microsoft.azure.kusto.data.ClientImpl.executeToJsonResult(ClientImpl.java:213)
    at com.microsoft.azure.kusto.data.ClientImpl.executeImpl(ClientImpl.java:173)
    at com.microsoft.azure.kusto.data.ClientImpl.lambda$execute$0(ClientImpl.java:122)
    at com.microsoft.azure.kusto.data.instrumentation.MonitoredActivity.invoke(MonitoredActivity.java:33)
    at com.microsoft.azure.kusto.data.ClientImpl.execute(ClientImpl.java:121)
    at com.microsoft.azure.kusto.data.ClientImpl.execute(ClientImpl.java:116)
    at com.microsoft.azure.kusto.data.ClientImpl.execute(ClientImpl.java:111)

我尝试使用 keytool 将 microsoft ca 证书添加到我的 JDK,但没有帮助。我仍然无法执行查询,我不明白为什么。

azure-data-explorer azure-java-sdk
1个回答
0
投票

com.microsoft.azure.kusto.data.exceptions.DataServiceException:尝试检索群集元数据时出现 IOException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

根据 Theri Muthu Selvam 的SO-Answer

  • 出现此问题的主要原因是我们系统中旨在防止安全漏洞的应用程序阻止了请求。
  • 使用 Java SDK 查询 Kusto 时,您可以忽略该错误。您需要将 SSL 证书导入到默认的 Java 密钥库。默认 Java 密钥库通常已经拥有所有 CA 根证书。但是,可能会有一些例外。例如,不同的根证书可能会签署摄取端点证书。

使用以下命令检查用于签署 Kusto 端点的 SSL 证书是否已存在于默认密钥库中:

命令:

keytool -list -v -keystore $JAVA_HOME/jre/lib/security/cacerts > temp.txt

命令:

使用以下命令将 SSL 证书导入到默认 Java 密钥库:

keytool -keystore  "$JAVA_HOME/jre/lib/security/cacerts" -import -alias "<some-meaningful-name>" -file "<downloaded-ssl-certificate-file>"
password: changeit

参考:

© www.soinside.com 2019 - 2024. All rights reserved.