Turn off nexus certificate validation for gradle builds?

Hi, I’m using a system where we sadly have a Nexus server with some SSL certificate problems. I cannot resolve them.

I’m trying to switch our projects to use gradle from maven. I have faced my first hurdle: when I run gradle build I get the following error:

Could not resolve org.slf4j:slf4j-api:1.7.22.
      > Could not get resource 'https://nexus.eng.myco/nexus/content/groups/myco-group/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.pom'.
         > Could not HEAD 'https://nexus.eng.myco/nexus/content/groups/myco-group/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.pom'.
            > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

This is not a self signed certificate. I think I need to turn off some certificate validation, but have no idea how to do it…

My build.gradle has this in it for nexus config:

repositories {

        maven {
            url "https://nexus.eng.myco/nexus/content/groups/myco-group/"
            credentials {
                username "$NEXUS_USER"
                password "$NEXUS_PASSWORD"
//        maven { url "http://repo.maven.apache.org/maven2" }

I am using Gradle 4.0.2. Thanks!

The same problem after 4 years. Gradle 6.8. Interesting facts - Maven doesn’t have problems both with downloading artifacts from the same repository, and with disabling cert validation