尝试使用 Gradle 编译 Fast-RTPS-Gen 时出现证书问题

ebe*_*des 1 java certificate gradle px4 ros2

我一直在拼命尝试使用 ROS2 和 PX4,但我无法编译所有必需的包:Fast-RTPS-Gen

了解PX4的人:

  • 我使用的是随 sdk 安装的 Gradle 版本 6.3,如 PX4 网站上所述。
  • 我已经从 Fast-RTPS-Gen 存储库下载了版本 1.0.4

当我尝试用 Gradle 编译它时,我有一个证书(参见问题末尾)。

我的问题是:我怎样才能绕过这个?因为我不会在 Java 上开发任何东西,所以我真的需要编译这一件事,我真的对绕过这个证书检查的最快、最肮脏的方法感兴趣。我尝试使用 keytool 从 Maven 存储库添加证书,但我无法让它工作。

> Task :buildIDLParser FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/home/evandro/Fast-RTPS-Gen/thirdparty/idl-parser/idl.gradle' line: 89

* What went wrong:
Could not determine the dependencies of task ':idl-parser:jar'.
> Could not resolve all files for configuration ':idl-parser:compile'.
   > Could not resolve org.antlr:antlr4:4.5.
     Required by:
         project :idl-parser
      > Could not resolve org.antlr:antlr4:4.5.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/antlr/antlr4/4.5/antlr4-4.5.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/antlr/antlr4/4.5/antlr4-4.5.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve org.antlr:antlr4:4.5.
     Required by:
         project :idl-parser
      > Could not resolve org.antlr:antlr4:4.5.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/antlr/antlr4/4.5/antlr4-4.5.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/antlr/antlr4/4.5/antlr4-4.5.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve org.antlr:stringtemplate:3.2.
     Required by:
         project :idl-parser
      > Could not resolve org.antlr:stringtemplate:3.2.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 653ms
4 actionable tasks: 2 executed, 2 up-to-date
Run Code Online (Sandbox Code Playgroud)

Gre*_*aro 6

据我所知,不可能通过配置禁用 JVM 证书验证。由于您的 证书验证失败https://repo.maven.apache.org(这在大多数系统上不应发生),我猜测您位于公司防火墙后面。

如果您使用的是 Windows,请尝试将环境变量设置JAVA_TOOL_OPTIONS为(准确):

-Djavax.net.ssl.trustStoreType=Windows-ROOT -Djavax.net.ssl.trustStore=NUL
Run Code Online (Sandbox Code Playgroud)

如果您使用的是 Mac,请尝试将其设置为:

-Djavax.net.ssl.trustStoreType=KeychainStore -Djavax.net.ssl.trustStore=/dev/null
Run Code Online (Sandbox Code Playgroud)

如果这些都不起作用,您可以复制 JVM 的现有密钥库,并使用 将您的公司证书添加到其中keytool,这很容易通过 Google 查找。在这种情况下,您将在环境变量中使用这些设置:

-Djavax.net.ssl.trustStore=/my/trust_store -Djavax.net.ssl.trustStorePassword=my_password
Run Code Online (Sandbox Code Playgroud)