title: Gradle use certificate authentication for repository
body: <p>The Problem</p>
  
  <p>I have a Android Gradle project which should pull a lib from my companys sonatype nexus server. The nexus server uses a certificate authentication. That means the client has a private certificate which authenticates and authorizes him against the nexus server.</p>
  
  <p>The problem is how to configure gradle to use my certificate (which is in the osx keystore).</p>
  
  <p>/app/build.gradle</p>
  
  <pre><code>repositories {
     // some other repositorys...
     ...
     maven {
        credentials {
           username = NEXUS_USERNAME
           password = NEXUS_PASSWORD
        }
        url 'https://prefix.server.com/nexus/content/repositories/artifactid'
     }
  }
  </code></pre>
  
  <p>Without giving a certificate the nexus server respont with:</p>
  
  <p>Error: Could not HEAD '<a href="https://prefix.server.com/nexus/content/repositories/artifactid/de/komoot/android/kmt-material-showcase/0.0.1/kmt-material-showcase-0.0.1.pom" rel="noreferrer">https://prefix.server.com/nexus/content/repositories/artifactid/de/komoot/android/kmt-material-showcase/0.0.1/kmt-material-showcase-0.0.1.pom</a>'. Received status code 400 from server: Bad Request</p>
  
  <p>My first solution was to try to configure the jvm to use the osx keychain for certificates. The same method helped me to push and publish libs/artifacts on the nexus server.</p>
  
  <p>/app/gradle.properties</p>
  
  <pre><code>org.gradle.jvmargs=-Djavax.net.ssl.keyStore=NONE -Djavax.net.ssl.keyStoreType=KeychainStore -Djavax.net.ssl.keyStorePassword=-
  </code></pre>
  
  <p>This doesn't work the gradle sync failed:
  Error:NONE (No such file or directory)</p>
  
  <p>It looks like the gradle expected to be  'NONE' of the paramter '-Djavax.net.ssl.keyStore'. I tryed several uper and lower case solutions but all failed.</p>
  
  <p>The second approach was to try it with </p>
  
  <pre><code>org.gradle.jvmargs=-Djavax.net.ssl.keyStoreType=KeychainStore
  </code></pre>
  
  <p>But the server respond with 400 again. Looks like the JVM args haven't been used.</p>
  
  <p>Any ideas or articles for this topic ?
  Hope someone can help me.</p>