Maven with HTTPS Repository and apache Wagon not working under proxy

1.1k Views Asked by At

We are developing a Maven application using Eclipse (12.18 version), and some of the libraries are located in a secure repository of the company.

I have configured the repository in the Maven Settings file like this:

<repositories>
   <repository>
       <id>MyRepository</id>
       <name>MyRepository</name>
       <url>https://companyUrl/repository/maven-3rdparty/</url>
       <releases>
          <enabled>true</enabled>
       </releases>
       <layout>default</layout>
   </repository>
</repositories>

Also, as our internet connection is behind a proxy, I have configured the proxy settings.

In the application, if I try to resolve the dependencies using "maven update" option, I don't get any error, just it doesn't download the jar file.

If I use the option "maven install", I am getting this error:

Failed to execute goal on project MyProject: Could not resolve dependencies for project my.project:MyProject:jar:0.0.1: Failed to collect dependencies at externalLibrary:jar:1.0: Failed to read artifact descriptor for externalLibrary:jar:1.0: Could not transfer artifact externalLibrary:pom:1.0 from/to MyRepository (https://companyUrl/repository/maven-3rdparty/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

I have tried to avoid SSL Certificate Verification using apache Wagon, and I haven't been successful. This is how I tried:

1- First I have configured the pom.xml of MyProject like this:

<build>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http-lightweight</artifactId>
            <version>3.3.2</version>
        </extension>
    </extensions>

    <plugins>    
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0.0</version>
            <executions>
              <execution>
              <phase>initialize</phase>
                <configuration>
                  <properties>
                    <property>
                      <name>maven.wagon.http.ssl.insecure</name>
                      <value>true</value>
                    </property>
                    <property>
                      <name>maven.wagon.http.ssl.allowall</name>
                      <value>true</value>
                    </property>
                    <property>
                      <name>maven.wagon.http.ssl.ignore.validity.dates</name>
                      <value>true</value>
                    </property>
                  </properties>
                </configuration>
              </execution>
            </executions>
          </plugin> 
    </plugins>
</build>

2- As the first option is not working, I have tried to load the wagon properties at the VM Arguments in the "Maven Build..." option:

-Dmaven.wagon.http.ssl.insecure=true 
-Dmaven.wagon.http.ssl.allowall=true 
-Dmaven.wagon.http.ssl.ignore.validity.dates=true

No one of this options have been successful.

So as the last option, I have installed the SSL Certificate of the repository in the CACERTS of my Java installation, and obviously this have worked.

BUT, we would like to be able to configure the repository without the need of installing the SSL Certificate.

What am I doing wrong? There is more configuration needed with apache Wagon? Am I missing something?

Thank you for reading.

0

There are 0 best solutions below