title: Maven can't download artifacts from HTTPS Nexus with mandatory authentication
body: <p>I have a Nexus that is available via HTTPS. Only authorized users have rights to access it. Using Maven, when all required artefacts are in local repo, I could even deploy building artefact. But when I remove some of required artifacts from local repository, the build fails.</p>
  
  <pre><code>Downloading: https://example.com/nexus/content/groups/all/org/springframework/spring-test-mvc/1.0.0.BUILD-SNAPSHOT/spring-test-mvc-1.0.0.BUILD-SNAPSHOT.pom
  [INFO] ------------------------------------------------------------------------
  [INFO] Reactor Summary:
  [INFO]
  [INFO] example - project1 ..................................... SUCCESS [0.500s]
  [INFO] example - project2 ..................................... FAILURE [2.951s]
  [INFO] example - project3 ...................................... SKIPPED
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 3.599s
  [INFO] Finished at: Tue May 15 13:58:13 EEST 2012
  [INFO] Final Memory: 6M/121M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal on project example - project2: Could not resolve dependencies for project com.example:example-project:jar:1.2.0-SNAPSHOT: Failed to collect dependencies for [com.example:example-project:jar:1.2.0-SNAPSHOT (compile), org.springframework:spring-beans:jar:3.1.1.RELEASE (compile), org.springframework:spring-context:jar:3.1.1.RELEASE (compile), org.springframework:spring-core:jar:3.1.1.RELEASE (compile), org.springframework:spring-test:jar:3.1.1.RELEASE (test), org.springframework:spring-web:jar:3.1.1.RELEASE (compile), org.apache.httpcomponents:httpclient:jar:4.1.1 (test), org.codehaus.jackson:jackson-mapper-asl:jar:1.9.6 (compile), org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT (test), junit:junit:jar:4.10 (test), org.mockito:mockito-all:jar:1.9.0 (test), org.hamcrest:hamcrest-all:jar:1.1 (compile), org.slf4j:slf4j-api:jar:1.6.1 (compile), org.slf4j:slf4j-log4j12:jar:1.6.1 (compile), log4j:log4j:jar:1.2.16 (compile), log4j:apache-log4j-extras:jar:1.1 (compile)]: Failed to read artifact descriptor for org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT: Could not transfer artifact org.springframework:spring-test-mvc:pom:1.0.0.BUILD-SNAPSHOT from/to nexus (https://example.com/nexus/content/groups/all): Not authorized, ReasonPhrase:Unauthorized. -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
  [ERROR]
  [ERROR] After correcting the problems, you can resume the build with the command
  [ERROR]   mvn &lt;goals&gt; -rf :grc-webclient-services
  </code></pre>
  
  <p>There is the following content in settings.xml of my user:</p>
  
  <pre><code>&lt;settings&gt;
  &lt;pluginGroups&gt;
      &lt;/pluginGroups&gt;
      &lt;proxies&gt;
      &lt;/proxies&gt;
      &lt;mirrors&gt;
        &lt;mirror&gt;
          &lt;id&gt;nexus&lt;/id&gt;
          &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
          &lt;url&gt;https://example.com/nexus/content/groups/all&lt;/url&gt;
        &lt;/mirror&gt;
      &lt;/mirrors&gt;
  
      &lt;profiles&gt;
          &lt;profile&gt;
  
              &lt;id&gt;nexus&lt;/id&gt;
  
              &lt;properties&gt;
                  &lt;sonar.jdbc.url&gt;jdbc:mysql://localhost:3306/sonardb?useUnicode=true&amp;amp;characterEncoding=utf8&lt;/sonar.jdbc.url&gt;
                  &lt;sonar.jdbc.driverClassName&gt;com.mysql.jdbc.Driver&lt;/sonar.jdbc.driverClassName&gt;
                  &lt;sonar.jdbc.username&gt;sonarusername&lt;/sonar.jdbc.username&gt;
                  &lt;sonar.jdbc.password&gt;sonarpw&lt;/sonar.jdbc.password&gt;
                  &lt;sonar.host.url&gt;http://localhost:9000/&lt;/sonar.host.url&gt;
              &lt;/properties&gt;
  
  
              &lt;repositories&gt;
                  &lt;repository&gt;
                      &lt;id&gt;central&lt;/id&gt;
                      &lt;url&gt;https://example.com/nexus/content/groups/all&lt;/url&gt;
                      &lt;releases&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/releases&gt;
                      &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;
                  &lt;/repository&gt;
              &lt;/repositories&gt;
              &lt;pluginRepositories&gt;
                  &lt;pluginRepository&gt;
                      &lt;id&gt;central&lt;/id&gt;
                      &lt;url&gt;https://example.com/nexus/content/groups/all&lt;/url&gt;
                      &lt;releases&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/releases&gt;
                      &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;
                  &lt;/pluginRepository&gt;
              &lt;/pluginRepositories&gt;
  
          &lt;/profile&gt;
      &lt;/profiles&gt;
  
      &lt;servers&gt;
          &lt;server&gt;
              &lt;id&gt;all&lt;/id&gt;
              &lt;username&gt;user&lt;/username&gt;
              &lt;password&gt;pw&lt;/password&gt;
          &lt;/server&gt;
          &lt;server&gt;
              &lt;id&gt;releases&lt;/id&gt;
              &lt;username&gt;user&lt;/username&gt;
              &lt;password&gt;pw&lt;/password&gt;
          &lt;/server&gt;
          &lt;server&gt;
              &lt;id&gt;snapshots&lt;/id&gt;
              &lt;username&gt;user&lt;/username&gt;
              &lt;password&gt;pw&lt;/password&gt;
          &lt;/server&gt;
      &lt;/servers&gt;
  
      &lt;activeProfiles&gt;
          &lt;activeProfile&gt;nexus&lt;/activeProfile&gt;
      &lt;/activeProfiles&gt;
  
  &lt;/settings&gt;
  </code></pre>
  
  <p>When I downloaded artifacts from this Nexus using wget, I had to add  --no-check-certificate key to skip server's certificate ('cause it's self-signed), and after that I could download it using wget.</p>
  
  <p>I fould Java key -Dsun.security.ssl.allowUnsafeRenegotiation=true, but it didn't change anything at all.</p>
  
  <p>After that I found that it's maybe not a self-signed certificate problem 'cause I've added server's certificate to trusted list using command:</p>
  
  <pre><code>keytool -keystore $JAVA_HOME/jre/lib/security/cacerts -import -file certificate.cer
  </code></pre>
  
  <p>Does somebody have an idea how I can download artifacts from Nexus in build-time?</p>