我一直在拼命尝试使用ROS2和PX4,但我无法编译所有必需的包:Fast-RTPS-Gen
让人们了解PX4:
当我尝试用 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
据我所知,不可能通过配置禁用 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 查找。在这种情况下,您将在环境变量中使用这些设置:
-Djavax.net.ssl.trustStore=/my/trust_store -Djavax.net.ssl.trustStorePassword=my_password
通过sudo编译解决了这个问题:
sudo env "PATH=$PATH" gradle assemble
我花了一整天的时间,因为我对 gradle 一无所知,最终它只是一个愚蠢的简单解决方案。我建议将此添加为 PX4 安装指南中的注释。