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