Verifique el estado del certificado con una llamada OCSP a través de http – Spring Boot.
Mi requisito es comprobar el certificado de usuario devuelto por la Autoridad Nacional con el punto final de OCSP a través de http.
Los DSAP deben utilizar el Protocolo de Estado de Certificado en Línea (OCSP) para realizar la verificación de estado contra la Autoridad.
curl –cert ABCDSAP……pem –key ABCDSAP…. clave privada.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
Puedo hacer una llamada de API REST para enviar el certificado obtenido en formato DER a OCSP.
No estoy seguro de cómo obtener la respuesta y analizarla para verificar el estado del certificado.
No puedo encontrar ninguna pista correcta para implementar en Spring Boot. Por favor, guíame sobre cómo proceder.
El siguiente código es lo que se me ocurrió
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());
}
}
Vi algunas implementaciones con Bouncy Castle: ¿alguien puede indicarme hacia la implementación correcta?
davy.ai
Si estás buscando una implementación de validación OCSP utilizando Bouncy Castle en Spring Boot, puedes intentar los siguientes pasos:
OcspValidator
en tu código principal:“`java
@Autowired
private OcspValidator validator;
public void validateUserCert(String userCert) {
X509Certificate certificate = extractCertificateFromUserCert(userCert);
validator.validate(certificate);
}
“`