mirror of
https://github.com/apple/swift-certificates
synced 2026-11-24 04:27:49 +00:00
Created a new OneOfPolicyBuilder
This is similar to the existing PolicyBuilder
The difference is that the new OneOfPolicyBuilder requires only one of the child policies to be valid, not necessarily all of them
A new struct, OneOfPolicies implements VerifierPolicy and can be constructed using OneOfPolicyBuilder
This can be used within a larger policy e.g.
let x = Verifier(rootCertificates: .init([])) {
RFC5280Policy(validationTime: .init()) // this must be met
OneOfPolicies {
SomethingPolicy() // one of these 2 must be met
SomethingElsePolicy() // one of these 2 must be met
}
}
The verifyingCriticalExtensions of OneOfPolicies is intersection of the verifyingCriticalExtensions of each of the child policies, because the overall policy will only be guaranteed to verify an extension if every child policy does so, because we don't know which child policies will actually be evaluated (we stop evaluating when any one passes)
OneOfPolicies will only fail if all of the child policies fail. In this case, the failure reason will be a concatenation of all the child failure reasons, with the word 'and' in between them
This PR also introduces AllOfPolicies
This is to allow users to specify a set of policies which must always be set, as a single item within a OneOfPolicies