title: X509 Certificate in a POST method
body: <p>I am building a <strong>REST</strong> service (using Spring) to be consumed by an application. It is a very simple REST, it only has 2 GET and 1 POST method.<br/>
  I would like to <strong>control who gets access to the POST method</strong>, so i thought about <strong>using X509 Certificates</strong> to do the job, the problem is i am already using HTTPS with server authentication, and it seems Client authentication  during the SSL handshake is out of the question.
  
  <p>The POST method in question acts like a proxy and here is the method structure:</p>
  
  <pre><code>@RequestMapping(value = "/proxy/{pack}", method = RequestMethod.POST)
      public ResponseEntity&lt;String&gt; requestService(
              @PathVariable(value = "pack") String pack,
              HttpServletResponse response, HttpServletRequest request, @RequestBody byte[] body)
              throws IOException, URISyntaxException {
  
          OutputStream writer = response.getOutputStream();
  
          //LOGIC HERE - USING CERTIFICATE IF POSSIBLE
  
          //PROXY STARTS HERE
          HttpClient client = HttpClientBuilder.create().build();
          HttpPost post = new HttpPost(URL_OK);
          HttpEntity entity = new ByteArrayEntity(body);
          post.setEntity(entity);
          HttpResponse postResponse = client.execute(post);
          byte[] result = EntityUtils.toByteArray(postResponse);
          writer.write(result);                   
  
          writer.flush();
          writer.close();
          return null;
      }
  </code></pre>
  
  <p>I am having a hard time trying to figure out a way of send/receive the certificate..
  Is there any way of <strong>attach the certificate to the HTTP header</strong>?</p>