-
Notifications
You must be signed in to change notification settings - Fork 7
Add resilient OCSP certificate revocation checker #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
madislm
wants to merge
21
commits into
web-eid:WE2-1030-use-platform-ocsp
Choose a base branch
from
madislm:AUT-2514
base: WE2-1030-use-platform-ocsp
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9e042cd
AUT-2473 Add ResilientOcspCertificateRevocationChecker
aarmam a57ce1c
AUT-2473 Separate handling unknown status from revoked for resilient …
aarmam 46dc128
AUT-2510 Disable thisUpdate in the past check for fallback OCSP service
madislm 59f8c2c
AUT-2552 Collect failed requests, add resilient OCSP specific exceptions
madislm b98e45f
AUT-2511 Collect failed retry results
madislm d299d3d
AUT-2547 Add support for two fallbacks
madislm 42dd199
AUT-2597 Update Resilience4j to version 2.3.0
madislm 1aafc02
AUT-2597 Improve collecting failed requests
madislm 1f07eb6
AUT-2597 Add tests for ResilientOcspCertificateRevocationChecker
madislm 2c280b2
AUT-2597 Use issuer CNs to get fallback OCSP services
madislm 3c3e117
AUT-2597 Move FallbackOcspService and FallbackOcspServiceConfiguratio…
madislm 8400be7
AUT-2597 Reorganize code in ResilientOcspCertificateRevocationChecker
madislm f7c137d
AUT-2597 Add a note regarding recursive fallbacks
madislm e7e768c
AUT-2623 Fix broken tests
madislm 3c27b2a
AUT-2623 Fix and improve tests
madislm 6d023f2
AUT-2618 Separate issuer certificates from OCSP responder certificates
madislm 5edbdd7
AUT-2562 Add data to RevocationInfo list returned by ResilientOcspCer…
madislm f528135
AUT-2677 Restructure responder certificate validation in FallbackOcsp…
madislm 8e45594
AUT-2677 Fix exception handling in OcspCertificateRevocationChecker a…
madislm 612ad2d
AUT-2677 Make OCSPClientException a checked exception, make its field…
madislm 93fa0b4
AUT-2677 Use Optional for getFallbackService
madislm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
64 changes: 64 additions & 0 deletions
64
src/main/java/eu/webeid/ocsp/exceptions/OCSPClientException.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright (c) 2020-2025 Estonian Information System Authority | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package eu.webeid.ocsp.exceptions; | ||
|
|
||
| public class OCSPClientException extends Exception { | ||
|
|
||
| private final byte[] responseBody; | ||
|
|
||
| private final Integer statusCode; | ||
|
|
||
| public OCSPClientException() { | ||
| this(null, null); | ||
| } | ||
|
|
||
| public OCSPClientException(String message) { | ||
| this(message, null, null); | ||
| } | ||
|
|
||
| public OCSPClientException(Throwable cause) { | ||
| this(null, cause, null, null); | ||
| } | ||
|
|
||
| public OCSPClientException(String message, Throwable cause) { | ||
| this(message, cause, null, null); | ||
| } | ||
|
|
||
| public OCSPClientException(String message, byte[] responseBody, Integer statusCode) { | ||
| this(message, null, responseBody, statusCode); | ||
| } | ||
|
|
||
| public OCSPClientException(String message, Throwable cause, byte[] responseBody, Integer statusCode) { | ||
| super(message, cause); | ||
| this.responseBody = responseBody; | ||
| this.statusCode = statusCode; | ||
| } | ||
|
|
||
| public byte[] getResponseBody() { | ||
| return responseBody; | ||
| } | ||
|
|
||
| public Integer getStatusCode() { | ||
| return statusCode; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
src/main/java/eu/webeid/ocsp/exceptions/UserCertificateUnknownException.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright (c) 2020-2025 Estonian Information System Authority | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package eu.webeid.ocsp.exceptions; | ||
|
|
||
| import eu.webeid.security.exceptions.AuthTokenException; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| import static eu.webeid.ocsp.exceptions.OcspResponderUriMessageAppender.appendResponderUri; | ||
|
|
||
| public class UserCertificateUnknownException extends AuthTokenException { | ||
|
|
||
| public UserCertificateUnknownException(String msg, URI ocspResponderUri) { | ||
| super(appendResponderUri("User certificate status is unknown: " + msg, ocspResponderUri)); | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
src/main/java/eu/webeid/ocsp/protocol/IssuerCommonName.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright (c) 2020-2025 Estonian Information System Authority | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package eu.webeid.ocsp.protocol; | ||
|
|
||
| import org.bouncycastle.asn1.x500.RDN; | ||
| import org.bouncycastle.asn1.x500.X500Name; | ||
| import org.bouncycastle.asn1.x500.style.BCStyle; | ||
| import org.bouncycastle.asn1.x500.style.IETFUtils; | ||
| import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; | ||
|
|
||
| import java.security.cert.CertificateEncodingException; | ||
| import java.security.cert.X509Certificate; | ||
| import java.util.Objects; | ||
| import java.util.Optional; | ||
|
|
||
| public class IssuerCommonName { | ||
|
|
||
| public static Optional<String> getIssuerCommonName(X509Certificate certificate) { | ||
| Objects.requireNonNull(certificate, "certificate"); | ||
| try { | ||
| X500Name x500Name = new JcaX509CertificateHolder(certificate).getIssuer(); | ||
| final RDN cn = x500Name.getRDNs(BCStyle.CN)[0]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will throw |
||
| return Optional.of(IETFUtils.valueToString(cn.getFirst().getValue())); | ||
| } catch (CertificateEncodingException e) { | ||
| return Optional.empty(); | ||
| } | ||
| } | ||
|
|
||
| private IssuerCommonName() { | ||
| throw new IllegalStateException("Utility class"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using only Common Name seems error-prone, using the full normalized Distinguished Name seems much safer.
For example, in the following (hypothetical) case there would be CN collision, but DN would work:
This applies to all locations where CN is used for lookup like OcspServiceProvider, AiaOcspService, FallbackOcspServiceConfiguration and AiaOcspServiceConfiguration.