0

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

想知道PX4的人:

  • 如 PX4 网站上所述,我正在使用随 sdk 安装的 Gradle 6.3 版。
  • 我已经从 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
4

2 回答 2

0

据我所知,无法通过配置禁用 JVM 证书验证。由于您遇到证书验证失败https://repo.maven.apache.org,这在大多数系统上都不应该发生,我猜您是在公司防火墙后面。

如果您在 Windows 上,请尝试将环境变量设置JAVA_TOOL_OPTIONS为(完全):

-Djavax.net.ssl.trustStoreType=Windows-ROOT -Djavax.net.ssl.trustStore=NUL

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

-Djavax.net.ssl.trustStoreType=KeychainStore -Djavax.net.ssl.trustStore=/dev/null

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

-Djavax.net.ssl.trustStore=/my/trust_store -Djavax.net.ssl.trustStorePassword=my_password
于 2022-01-03T17:01:57.817 回答
0

设法通过使用 sudo 编译来解决它:

sudo env "PATH=$PATH" gradle assemble

因为我对 gradle 一无所知,所以花了我一整天的时间,结果它只是一个愚蠢的简单解决方案。我建议将此作为注释添加到 PX4 安装指南中。

于 2022-01-04T09:05:06.513 回答