@@ -32,16 +32,16 @@ extension SignatureProviderProtocol {
32
32
policies. append ( RFC5280Policy ( validationTime: expiryValidationTime ?? now) )
33
33
policies
34
34
. append ( _OCSPVerifierPolicy (
35
+ failureMode: . hard,
35
36
httpClient: httpClient,
36
- mode: . strict,
37
37
validationTime: revocationValidationTime ?? now
38
38
) )
39
39
case ( . enabled( let expiryValidationTime) , . allowSoftFail( let revocationValidationTime) ) :
40
40
policies. append ( RFC5280Policy ( validationTime: expiryValidationTime ?? now) )
41
41
policies
42
42
. append ( _OCSPVerifierPolicy (
43
+ failureMode: . soft,
43
44
httpClient: httpClient,
44
- mode: . allowSoftFail,
45
45
validationTime: revocationValidationTime ?? now
46
46
) )
47
47
case ( . enabled( let expiryValidationTime) , . disabled) :
@@ -51,17 +51,17 @@ extension SignatureProviderProtocol {
51
51
policies. append ( RFC5280Policy ( validationTime: revocationValidationTime ?? now) )
52
52
policies
53
53
. append ( _OCSPVerifierPolicy (
54
+ failureMode: . hard,
54
55
httpClient: httpClient,
55
- mode: . strict,
56
56
validationTime: revocationValidationTime ?? now
57
57
) )
58
58
case ( . disabled, . allowSoftFail( let revocationValidationTime) ) :
59
59
// Always do expiry check (and before) if revocation check is enabled
60
60
policies. append ( RFC5280Policy ( validationTime: revocationValidationTime ?? now) )
61
61
policies
62
62
. append ( _OCSPVerifierPolicy (
63
+ failureMode: . soft,
63
64
httpClient: httpClient,
64
- mode: . allowSoftFail,
65
65
validationTime: revocationValidationTime ?? now
66
66
) )
67
67
case ( . disabled, . disabled) :
@@ -127,16 +127,15 @@ struct _OCSPVerifierPolicy: VerifierPolicy {
127
127
> ( )
128
128
129
129
private var underlying : OCSPVerifierPolicy < _OCSPRequester >
130
- private let mode : Mode
131
130
132
131
let verifyingCriticalExtensions : [ ASN1ObjectIdentifier ] = [ ]
133
132
134
- init ( httpClient : HTTPClient , mode : Mode , validationTime: Date ) {
133
+ init ( failureMode : OCSPFailureMode , httpClient : HTTPClient , validationTime: Date ) {
135
134
self . underlying = OCSPVerifierPolicy (
135
+ failureMode: failureMode,
136
136
requester: _OCSPRequester ( httpClient: httpClient) ,
137
137
validationTime: validationTime
138
138
)
139
- self . mode = mode
140
139
}
141
140
142
141
mutating func chainMeetsPolicyRequirements( chain: UnverifiedCertificateChain ) async -> PolicyEvaluationResult {
@@ -147,32 +146,10 @@ struct _OCSPVerifierPolicy: VerifierPolicy {
147
146
148
147
// This makes HTTP requests
149
148
let result = await self . underlying. chainMeetsPolicyRequirements ( chain: chain)
150
- let actualResult : PolicyEvaluationResult
151
- switch result {
152
- case . meetsPolicy:
153
- actualResult = result
154
- case . failsToMeetPolicy( let reason) :
155
- switch self . mode {
156
- case . strict:
157
- actualResult = result
158
- case . allowSoftFail:
159
- // Allow 'unknown' status and failed OCSP request in this mode
160
- if reason. lowercased ( ) . contains ( " revoked through ocsp " ) {
161
- actualResult = result
162
- } else {
163
- actualResult = . meetsPolicy
164
- }
165
- }
166
- }
167
149
168
150
// Save result to cache
169
- self . cache [ chain] = ( result: actualResult, expires: . now( ) + Self. cacheTTL)
170
- return actualResult
171
- }
172
-
173
- enum Mode {
174
- case strict
175
- case allowSoftFail
151
+ self . cache [ chain] = ( result: result, expires: . now( ) + Self. cacheTTL)
152
+ return result
176
153
}
177
154
}
178
155
0 commit comments