Search in sources :

Example 21 with OCSPReq

use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.

the class OcspCheckerTest method testGeneratingOcspRequest.

@Test
public void testGeneratingOcspRequest() throws Exception {
    OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
    ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
    Certificate certificate = trustedCertBc;
    OCSPReq ocspReq = ocspChecker.generateOcspRequest(certificate);
    assertThat(ocspReq, is(notNullValue()));
    assertThat(ocspReq.getRequestList()[0].getCertID().getSerialNumber(), equalTo(certificate.getSerialNumber().getValue()));
}
Also used : OCSPReq(org.bouncycastle.cert.ocsp.OCSPReq) SecurityLogger(ddf.security.audit.SecurityLogger) X509Certificate(java.security.cert.X509Certificate) Certificate(org.bouncycastle.asn1.x509.Certificate) Test(org.junit.Test)

Example 22 with OCSPReq

use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.

the class OcspCheckerTest method testSendOcspRequestsRevokedStatus.

@Test
public void testSendOcspRequestsRevokedStatus() throws Exception {
    revokedEndpoints.add(new URI("https://revokedurl:8993"));
    brokenEndpoints.add(new URI(EMBEDDED_OCSP_SERVER_URL));
    List<URI> ocspServerUrls = new ArrayList<>(revokedEndpoints);
    OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
    ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
    ocspChecker.setOcspEnabled(true);
    ocspChecker.setOcspServerUrls(ocspServerUrls.stream().map(URI::toString).collect(Collectors.toList()));
    OCSPReq ocspReq = ocspChecker.generateOcspRequest(trustedCertBc);
    Map<URI, CertificateStatus> ocspStatuses = ocspChecker.sendOcspRequests(trustedCertX509, ocspReq);
    assertStatuses(ocspStatuses);
}
Also used : OCSPReq(org.bouncycastle.cert.ocsp.OCSPReq) CertificateStatus(org.bouncycastle.cert.ocsp.CertificateStatus) ArrayList(java.util.ArrayList) URI(java.net.URI) SecurityLogger(ddf.security.audit.SecurityLogger) Test(org.junit.Test)

Example 23 with OCSPReq

use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.

the class OcspCheckerTest method testSendOcspRequestsGoodEmbeddedUrl.

@Test
public void testSendOcspRequestsGoodEmbeddedUrl() throws Exception {
    unknownEndpoints.add(new URI("https://unknownurl:8993"));
    unknownEndpoints.add(new URI("https://unknownurl2:8993"));
    goodEndpoints.add(new URI(EMBEDDED_OCSP_SERVER_URL));
    List<URI> ocspServerUrls = new ArrayList<>(unknownEndpoints);
    OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
    ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
    ocspChecker.setOcspEnabled(true);
    ocspChecker.setOcspServerUrls(ocspServerUrls.stream().map(URI::toString).collect(Collectors.toList()));
    OCSPReq ocspReq = ocspChecker.generateOcspRequest(trustedCertBc);
    Map<URI, CertificateStatus> ocspStatuses = ocspChecker.sendOcspRequests(trustedCertX509, ocspReq);
    assertStatuses(ocspStatuses);
}
Also used : OCSPReq(org.bouncycastle.cert.ocsp.OCSPReq) CertificateStatus(org.bouncycastle.cert.ocsp.CertificateStatus) ArrayList(java.util.ArrayList) URI(java.net.URI) SecurityLogger(ddf.security.audit.SecurityLogger) Test(org.junit.Test)

Aggregations

OCSPReq (org.bouncycastle.cert.ocsp.OCSPReq)23 CertificateStatus (org.bouncycastle.cert.ocsp.CertificateStatus)12 URI (java.net.URI)11 SecurityLogger (ddf.security.audit.SecurityLogger)10 Test (org.junit.Test)10 X509Certificate (java.security.cert.X509Certificate)8 ArrayList (java.util.ArrayList)8 BasicOCSPResp (org.bouncycastle.cert.ocsp.BasicOCSPResp)7 OCSPResp (org.bouncycastle.cert.ocsp.OCSPResp)7 IOException (java.io.IOException)6 CertificateID (org.bouncycastle.cert.ocsp.CertificateID)6 OCSPReqBuilder (org.bouncycastle.cert.ocsp.OCSPReqBuilder)5 SingleResp (org.bouncycastle.cert.ocsp.SingleResp)5 JcaDigestCalculatorProviderBuilder (org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder)5 BigInteger (java.math.BigInteger)4 Date (java.util.Date)4 X509CertificateHolder (org.bouncycastle.cert.X509CertificateHolder)4 RevokedStatus (org.bouncycastle.cert.ocsp.RevokedStatus)4 OperatorCreationException (org.bouncycastle.operator.OperatorCreationException)4 InputStream (java.io.InputStream)3