title: In Jenkins pipeline, what is the correct way to perform mutual-authentication REST requests?
body: <p>I am calling a REST service from a Jenkins Pipeline. This REST service uses mutual authentication so I must provide a client certificate to authenticate.</p>
  
  <p>I could store the certificate with my Jenkinsfile in Git - could I then pass this cert to the REST call?</p>
  
  <p>This is performed in cURL with the --cert param:</p>
  
  <pre class="lang-sh prettyprint-override"><code>curl -H "Content-Type: application/json" -H "Accept: application/json" \
  --cert ens.p12 \
  https://hostname:9000/api/bakery -k
  </code></pre>
  
  <p>How do we get it so that the cert will be used in the Groovy request?</p>
  
  <pre><code>def get = new URL("https://hostname:9000/api/bakery").openConnection();
  get.setRequestMethod("GET")
  get.setRequestProperty("Content-Type", "application/json")
  get.getInputStream().getText()
  </code></pre>