-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use system time in OcspService.validateResponderCertificate()
- Loading branch information
Showing
5 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
package eu.webeid.security.validator.certvalidators; | ||
|
||
import eu.webeid.security.exceptions.CertificateExpiredException; | ||
import eu.webeid.security.exceptions.CertificateNotTrustedException; | ||
import eu.webeid.security.exceptions.JceException; | ||
import eu.webeid.security.exceptions.UserCertificateOCSPCheckFailedException; | ||
|
@@ -251,14 +252,28 @@ void whenOcspResponseUnknown_thenThrows() throws Exception { | |
} | ||
|
||
@Test | ||
void whenOcspResponseCANotTrusted_thenThrows() throws Exception { | ||
void whenOcspResponseCACertExpired_thenThrows() throws Exception { | ||
final SubjectCertificateNotRevokedValidator validator = getSubjectCertificateNotRevokedValidatorWithAiaOcsp( | ||
getMockedResponse(getOcspResponseBytesFromResources("ocsp_response_unknown.der")) | ||
); | ||
assertThatExceptionOfType(CertificateNotTrustedException.class) | ||
assertThatExceptionOfType(CertificateExpiredException.class) | ||
.isThrownBy(() -> | ||
validator.validateCertificateNotRevoked(estEid2018Cert)) | ||
.withMessage("Certificate [email protected], CN=TEST of SK OCSP RESPONDER 2020, OU=OCSP, O=AS Sertifitseerimiskeskus, C=EE is not trusted"); | ||
.withMessage("AIA OCSP responder certificate has expired"); | ||
} | ||
|
||
@Test | ||
void whenOcspResponseCACertNotTrusted_thenThrows() throws Exception { | ||
final SubjectCertificateNotRevokedValidator validator = getSubjectCertificateNotRevokedValidatorWithAiaOcsp( | ||
getMockedResponse(getOcspResponseBytesFromResources("ocsp_response_unknown.der")) | ||
); | ||
try (var mockedClock = mockStatic(DateAndTime.DefaultClock.class)) { | ||
mockDate("2021-09-18T00:16:25", mockedClock); | ||
assertThatExceptionOfType(CertificateNotTrustedException.class) | ||
.isThrownBy(() -> | ||
validator.validateCertificateNotRevoked(estEid2018Cert)) | ||
.withMessage("Certificate [email protected], CN=TEST of SK OCSP RESPONDER 2020, OU=OCSP, O=AS Sertifitseerimiskeskus, C=EE is not trusted"); | ||
} | ||
} | ||
|
||
@Test | ||
|