Skip to content

Commit b1510fa

Browse files
committed
OSCP response handling
1 parent c444a1e commit b1510fa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Sources/PackageCollectionsSigning/Certificate/CertificatePolicy.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,21 @@ private struct BoringSSLOCSPClient {
375375

376376
group.notify(queue: callbackQueue) {
377377
// If there's no result then something must have gone wrong
378-
guard !results.isEmpty, results.compactMap({ $0.failure }).isEmpty else {
378+
guard !results.isEmpty else {
379+
return wrappedCallback(.failure(CertificatePolicyError.ocspFailure))
380+
}
381+
382+
let statuses = results.compactMap { $0.success }
383+
// We got results but they are all failures
384+
guard !statuses.isEmpty else {
379385
diagnosticsEngine.emit(error: "OCSP failed. All results: \(results)")
380386
return wrappedCallback(.failure(CertificatePolicyError.ocspFailure))
381387
}
382-
// Is there response "bad status" response?
388+
// If at least one response is "bad status" then the chain is invalid
383389
guard results.compactMap({ $0.success }).first(where: { !$0 }) == nil else {
384390
return wrappedCallback(.failure(CertificatePolicyError.invalidCertChain))
385391
}
392+
// Good status
386393
wrappedCallback(.success(()))
387394
}
388395
}

0 commit comments

Comments
 (0)