title: Check the certificate Status with OCSP call over http - Spring Boot
body: <p>My requirement is to check the User certificate returned by national Authority with OCSP endpoint over http.</p>
  <p>DSAPs should use Online Certificate Status Protocol (OCSP) to do the status verification against Authority.</p>
  <pre><code>curl --cert ABCDSAP......pem --key ABCDSAP.... private key.key.pem --cacert ABCManagementCAStaging.cer.txt https://ocsp.staging.abc.gov.cs --data-binary @request.der --header &quot;Content-Type:application/ocsp-requests&quot; --header &quot;ocsp.staging.abc.gov.cs&quot; --output stgnca-ocsp-resp.der --insecure -v &gt;&gt; _STG_CDNS.txt 2&gt;&amp;1
  </code></pre>
  <p>I can do a rest API post call to send the certificate obtained in the DER format to OCSP.</p>
  <p>im not sure how to get the response back and parse it to check the status of the certificate.</p>
  <p>Not able to find any right pointers to implement in spring boot. Please guide me on how to proceed.</p>
  <p>The below code is what i came up with</p>
  <pre><code>public OcspResponse validateUserCert(String userCert) {
      try {
          HttpHeaders headers = new HttpHeaders();
          headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
          headers.add(HttpHeaders.HOST, &quot;ocsp.staging.abc.gov.ab&quot;);
  
          OcspRequest request = new OcspRequest(userCert.getBytes(StandardCharsets.UTF_8));
  
          return singpassRestTemplate
                  .exchange(
                          ocspProperties.getUrl(),
                          HttpMethod.POST,
                          new HttpEntity&lt;&gt;(request, headers),
                          OcspResponse.class)
                  .getBody();
      } catch (Exception e) {
          log.error(e.getMessage(), e);
          throw new DigitalSigningWebhookServerError(
              DigitalSigningErrorCode.OCSP_EXCEPTION,
              DigitalSigningErrorCode.OCSP_EXCEPTION.getDescription());
      }
  }
  </code></pre>
  <p>I saw some implementation with Bouncy Castle - Can someone point me towards the right implementation</p>