javagradlecertificateros2px4

Problem with certificate while trying to compile Fast-RTPS-Gen with Gradle


I've been desperately trying to use ROS2 and PX4, but I can't compile all of the necessary packages: Fast-RTPS-Gen

For people to know PX4:

When I try to compile it with Gradle, I have a certificate (see end of question).

My question is: how can I bypass this? Since I'm not gonna develop anything on Java, I just really need this one thing to compile, I'm really interested in the quickest, dirtiest way I can bypass this certificate check. I have tried adding a certificate from the Maven repo with keystool but I just can't get it to work.

> 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

Solution

  • Managed to solve it by compiling with sudo:

    sudo env "PATH=$PATH" gradle assemble
    

    Took me the whole day since I know nothing about gradle, and it ended up just being a stupid simple solution. I proposed to add this as a note on the PX4 install guide.