Problem with certificate while trying to compile with Gradle - java

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:
I am using Gradle version 6.3 installed with sdk, as explained on the PX4 website.
I have download the version 1.0.4 from the Fast-RTPS-Gen repository
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

As far as I am aware, it is not possible to disable JVM cert validation by configuration. As you are getting a cert validation failure for https://repo.maven.apache.org, which should not happen on most systems, I am going to guess that you are behind a corporate firewall.
If you are on Windows, try setting the environment variable JAVA_TOOL_OPTIONS to (exactly):
-Djavax.net.ssl.trustStoreType=Windows-ROOT -Djavax.net.ssl.trustStore=NUL
If you are on Mac, try setting it to:
-Djavax.net.ssl.trustStoreType=KeychainStore -Djavax.net.ssl.trustStore=/dev/null
If none of those work, you can copy the existing keystore of your JVM, and add your corporate certs to it using keytool, which is easy enough to look up with Google. In this case you would use these settings in the env var:
-Djavax.net.ssl.trustStore=/my/trust_store -Djavax.net.ssl.trustStorePassword=my_password

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.

Related

gradlew commandline options for ssl insecure and allowall

This seems like a trivial answer that I should be able to find easily but I can't. I have a https repo with self signed certificates and I have imported the certs to the store using keytool command but I still get the PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target errors.
As a remedy I use these options when building with maven : -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true.
Question is, what are equivalent commandline options when running ./gradlew build ? Just can't seem to find this anywhere.

Certification error when starting project with Android Emulator

I am trying to start the default flutter app on a company MAC laptop which is connected behind a proxy.
Upon clicking debug on my Android Studio (Connected to an Android Emulator API 28 (also tried API 30)) I am
gettting the following error:
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve io.flutter:flutter_embedding_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.
Required by:
project :app
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/flutter_embedding_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/flutter_embedding_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.pom'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
Could not resolve io.flutter:x86_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.
Required by:
project :app
> Could not resolve io.flutter:x86_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.pom'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
Could not resolve io.flutter:x86_64_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.
Required by:
project :app
> Could not resolve io.flutter:x86_64_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_64_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_64_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.pom'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
I was getting proxy errors prior to this which I've fixed by adding a gradle.properties file under the .gradle folder with following data:
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=myId
systemProp.http.proxyPassword=myPass
systemProp.http.nonProxyHosts=localhost,127.0.0.1,0.0.0.0,.company.com
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=myId
systemProp.https.proxyPassword=myPass
systemProp.http.nonProxyHosts=localhost,127.0.0.1,0.0.0.0,.company.com
I do have a truststore file which I use for other projects where it is needed such as Spring, JBoss, Tomcat related projects.
Unsure if this is the truststore file that is required
The file type is Java keyStore.
Inside the project, there is a gradlew file. Within there I added the following to point to that truststore file.
-Djavax.net.ssl.trustStore=truststore
This makes no difference and end up with same error. The path to truststore file is correct. Cos for testing, I added the following.
And it does throw a different error saying file not found as expected.
-Djavax.net.ssl.trustStore=truststore12345
This data seems to indicate some cert issues now. I am only using this locally.
Alternatively, is there a way I could by pass this security check?
Please advice. Thank you.

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException

Situation :
(1) I am on Android Studio 4.1 and trying to build a sample Android Application
(2) I am behind the Proxy and Proxy settings working fine as I am able to download and install SDKs
I am getting the below error : I tried all possible steps adding the certificates using keytool.exe
eg : keytool.exe -import -trustcacerts -alias androidstudiocerts -file dlgooglecom.cer -keystore "C:\Program Files\Android\Android Studio\jre\jre\lib\security\cacerts"
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 all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:4.1.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:4.1.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I wanted to know :
(1) In the Android Studio Settings we have an option for http then why it is taking "https" to probe the site?Why not http?
(2) SDK Manager works fine for downloading the sdks and related build tools.
(3) tried with 5-6 differernt gradle:4.X.X. versions , no effect
(3) There are several JAVA (one from android studio, another from Oracle JAVA : Program Files\Java\jdk-15.0.1) and I have added the certificates to both C:\Program Files\Android\Android Studio\jre\jre\lib\security\ as well as C:\Program Files\Java\jdk-15.0.1\lib\security but still the sam error
(4) Already restarted the PC and invalidated cache and Android Studio Restart - No effect
(5) Which Software part is throwing this error? JAVA or Android Studio or something else?
(6)Is there any other location where I can get the full detailed logs of this error?
And most important :
(7) How to fix this now?
This seems to be network issue, can you try adding certificate into android studio by navigating to android studio>settings>tools>Server Certificates> add .crt file and tick "Accept non-trusted certificates automatically" if you want it automatically accepting certificates.
After this try running app again.

Trying to mod MC Forge 1.12.2, but SetupDecompWorkspace not working

I am trying to make a mod for Minecraft Forge 1.12.2, mdk file forge-1.12.2-14.23.5.2854-mdk. Problem is, when i right-click inside this folder, open Powershell and run the ./gradlew setupDecompWorkspace eclipse command, it comes up with an error log:
forge-1.12.2-14.23.5.2854-mdk> ./gradlew setupDecompWorkspace eclipse To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradlDaemon will be stopped at the end of the build stopping after processing
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'forge-1.12.2-14.23.5.2854-mdk'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve net.minecraftforge.gradle:ForgeGradle:3.+.
Required by:
project :
> Failed to list versions for net.minecraftforge.gradle:ForgeGradle.
> Unable to load Maven meta-data from https://files.minecraftforge.net/maven/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml.
> Could not get resource 'https://files.minecraftforge.net/maven/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml'.
> Could not GET 'https://files.minecraftforge.net/maven/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Failed to list versions for net.minecraftforge.gradle:ForgeGradle.
> Unable to load Maven meta-data from https://jcenter.bintray.com/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml.
> Could not get resource 'https://jcenter.bintray.com/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml'.
> Could not GET 'https://jcenter.bintray.com/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Failed to list versions for net.minecraftforge.gradle:ForgeGradle.
> Unable to load Maven meta-data from https://repo.maven.apache.org/maven2/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml.
> Could not get resource 'https://repo.maven.apache.org/maven2/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml'.
> Could not GET 'https://repo.maven.apache.org/maven2/net/minecraftforge/gradle/ForgeGradle/maven-metadata.xml'.
> 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
BUILD FAILED in 6s
Could somebody please help me with this? I am not sure what else to try.
(Couldn't make a comment because not enough reputation) They might have changed the way how you should set up your mod environment. According to their instructions, you should first run the command gradlew genEclipseRuns, which will generate the runClient and runServer configurations that will allow you to click the "Run" button in eclipse. After that, you should run the command gradlew eclipse. This should set up your Eclipse folder. What I usually do after that is go into Eclipse, go to File, then Import, then in the search bar search for Existing Gradle Projects. Put in the directory text box the directory of the Forge MDK you have extracted, and click done. It should start importing the necessary libraries needed. After that, you are all set.
It seems that the links that Forge is trying to extract data from are outdated because if you try clicking on them they lead to a 404 Error. (The file must have been deleted).

PKIX path building failed when running Teamprise-ant task

I am having an xml which will connect to tfs through https connection to get latest files from it. I am trying to run this as ant task invoked from my java scheduler. When i try to invoke it I am getting the following error message :
An error occurred: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
But if i invoke the ant task from a bat file directly, it is working fine without any issues.
Kindly help me out on how to handle the execption when invoking from java
These steps, based on Oracle instructions, worked for me:
Get InstallCert.java (the link in Oracle's instructions is broken)
Compile and execute java InstallCert [host]:[port]
enter '1'
Copy and rename the newly created jssecacerts file as %JAVA_HOME%\jre\lib\security\cacerts (backup the original, just in case)
Rerun Ant, it should not complain about certificate anymore
There may be other solutions as well.

Categories

Resources