1313//===----------------------------------------------------------------------===//
1414
1515import Benchmark
16- import X509
16+ @ _spi ( FixedExpiryValidationTime ) import X509
1717import Foundation
1818import Crypto
1919import SwiftASN1
@@ -50,10 +50,10 @@ func testTrivialChainBuilding() async -> Int {
5050 let roots = CertificateStore ( [ TestCertificate . ca1] )
5151
5252 var verifier = Verifier ( rootCertificates: roots) {
53- RFC5280Policy ( validationTime : TestCertificate . referenceTime)
53+ RFC5280Policy ( fixedExpiryValidationTime : TestCertificate . referenceTime)
5454 }
5555 let result = await verifier. validate (
56- leafCertificate : TestCertificate . localhostLeaf,
56+ leaf : TestCertificate . localhostLeaf,
5757 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
5858 )
5959
@@ -67,9 +67,11 @@ func testTrivialChainBuilding() async -> Int {
6767func testExtraRootsAreIgnored( ) async -> Int {
6868 let roots = CertificateStore ( [ TestCertificate . ca1, TestCertificate . ca2] )
6969
70- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
70+ var verifier = Verifier ( rootCertificates: roots) {
71+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
72+ }
7173 let result = await verifier. validate (
72- leafCertificate : TestCertificate . localhostLeaf,
74+ leaf : TestCertificate . localhostLeaf,
7375 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
7476 )
7577
@@ -83,9 +85,11 @@ func testExtraRootsAreIgnored() async -> Int {
8385func testPuttingRootsInTheIntermediariesIsntAProblem( ) async -> Int {
8486 let roots = CertificateStore ( [ TestCertificate . ca1, TestCertificate . ca2] )
8587
86- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
88+ var verifier = Verifier ( rootCertificates: roots) {
89+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
90+ }
8791 let result = await verifier. validate (
88- leafCertificate : TestCertificate . localhostLeaf,
92+ leaf : TestCertificate . localhostLeaf,
8993 intermediates: CertificateStore ( [ TestCertificate . intermediate1, TestCertificate . ca1, TestCertificate . ca2] )
9094 )
9195
@@ -99,9 +103,11 @@ func testPuttingRootsInTheIntermediariesIsntAProblem() async -> Int {
99103func testSupportsCrossSignedRootWithoutTrouble( ) async -> Int {
100104 let roots = CertificateStore ( [ TestCertificate . ca2] )
101105
102- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
106+ var verifier = Verifier ( rootCertificates: roots) {
107+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
108+ }
103109 let result = await verifier. validate (
104- leafCertificate : TestCertificate . localhostLeaf,
110+ leaf : TestCertificate . localhostLeaf,
105111 intermediates: CertificateStore ( [ TestCertificate . intermediate1, TestCertificate . ca1CrossSignedByCA2] )
106112 )
107113
@@ -115,9 +121,11 @@ func testSupportsCrossSignedRootWithoutTrouble() async -> Int {
115121func testBuildsTheShorterPathInTheCaseOfCrossSignedRoots( ) async -> Int {
116122 let roots = CertificateStore ( [ TestCertificate . ca1, TestCertificate . ca2] )
117123
118- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
124+ var verifier = Verifier ( rootCertificates: roots) {
125+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
126+ }
119127 let result = await verifier. validate (
120- leafCertificate : TestCertificate . localhostLeaf,
128+ leaf : TestCertificate . localhostLeaf,
121129 intermediates: CertificateStore ( [
122130 TestCertificate . intermediate1, TestCertificate . ca2CrossSignedByCA1, TestCertificate . ca1CrossSignedByCA2,
123131 ] )
@@ -133,9 +141,11 @@ func testBuildsTheShorterPathInTheCaseOfCrossSignedRoots() async -> Int {
133141func testPrefersToUseIntermediatesWithSKIThatMatches( ) async -> Int {
134142 let roots = CertificateStore ( [ TestCertificate . ca1] )
135143
136- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
144+ var verifier = Verifier ( rootCertificates: roots) {
145+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
146+ }
137147 let result = await verifier. validate (
138- leafCertificate : TestCertificate . localhostLeaf,
148+ leaf : TestCertificate . localhostLeaf,
139149 intermediates: CertificateStore ( [ TestCertificate . intermediate1, TestCertificate . intermediate1WithoutSKIAKI] )
140150 )
141151
@@ -149,9 +159,11 @@ func testPrefersToUseIntermediatesWithSKIThatMatches() async -> Int {
149159func testPrefersNoSKIToNonMatchingSKI( ) async -> Int {
150160 let roots = CertificateStore ( [ TestCertificate . ca1] )
151161
152- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
162+ var verifier = Verifier ( rootCertificates: roots) {
163+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
164+ }
153165 let result = await verifier. validate (
154- leafCertificate : TestCertificate . localhostLeaf,
166+ leaf : TestCertificate . localhostLeaf,
155167 intermediates: CertificateStore ( [
156168 TestCertificate . intermediate1WithIncorrectSKIAKI, TestCertificate . intermediate1WithoutSKIAKI,
157169 ] )
@@ -167,9 +179,11 @@ func testPrefersNoSKIToNonMatchingSKI() async -> Int {
167179func testRejectsRootsThatDidNotSignTheCertBeforeThem( ) async -> Int {
168180 let roots = CertificateStore ( [ TestCertificate . ca1WithAlternativePrivateKey, TestCertificate . ca2] )
169181
170- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
182+ var verifier = Verifier ( rootCertificates: roots) {
183+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
184+ }
171185 let result = await verifier. validate (
172- leafCertificate : TestCertificate . localhostLeaf,
186+ leaf : TestCertificate . localhostLeaf,
173187 intermediates: CertificateStore ( [
174188 TestCertificate . ca1CrossSignedByCA2, TestCertificate . ca2CrossSignedByCA1, TestCertificate . intermediate1,
175189 ] )
@@ -186,10 +200,10 @@ func testPolicyFailuresCanFindLongerPaths() async -> Int {
186200
187201 var verifier = Verifier ( rootCertificates: roots) {
188202 FailIfCertInChainPolicy ( forbiddenCert: TestCertificate . ca1)
189- RFC5280Policy ( validationTime : TestCertificate . referenceTime)
203+ RFC5280Policy ( fixedExpiryValidationTime : TestCertificate . referenceTime)
190204 }
191205 let result = await verifier. validate (
192- leafCertificate : TestCertificate . localhostLeaf,
206+ leaf : TestCertificate . localhostLeaf,
193207 intermediates: CertificateStore ( [
194208 TestCertificate . intermediate1, TestCertificate . ca2CrossSignedByCA1, TestCertificate . ca1CrossSignedByCA2,
195209 ] )
@@ -205,9 +219,11 @@ func testPolicyFailuresCanFindLongerPaths() async -> Int {
205219func testSelfSignedCertsAreTrustedWhenInTrustStore( ) async -> Int {
206220 let roots = CertificateStore ( [ TestCertificate . ca1, TestCertificate . isolatedSelfSignedCert] )
207221
208- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
222+ var verifier = Verifier ( rootCertificates: roots) {
223+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
224+ }
209225 let result = await verifier. validate (
210- leafCertificate : TestCertificate . isolatedSelfSignedCert,
226+ leaf : TestCertificate . isolatedSelfSignedCert,
211227 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
212228 )
213229
@@ -232,7 +248,7 @@ func testTrustRootsCanBeNonSelfSignedLeaves() async -> Int {
232248
233249 var verifier = Verifier ( rootCertificates: roots) { IgnoreBasicConstraintsPolicy ( ) }
234250 let result = await verifier. validate (
235- leafCertificate : TestCertificate . localhostLeaf,
251+ leaf : TestCertificate . localhostLeaf,
236252 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
237253 )
238254
@@ -246,9 +262,11 @@ func testTrustRootsCanBeNonSelfSignedLeaves() async -> Int {
246262func testTrustRootsCanBeNonSelfSignedIntermediates( ) async -> Int {
247263 let roots = CertificateStore ( [ TestCertificate . intermediate1] )
248264
249- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
265+ var verifier = Verifier ( rootCertificates: roots) {
266+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
267+ }
250268 let result = await verifier. validate (
251- leafCertificate : TestCertificate . localhostLeaf,
269+ leaf : TestCertificate . localhostLeaf,
252270 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
253271 )
254272
@@ -275,9 +293,11 @@ func testWePoliceCriticalExtensionsOnLeafCerts() async -> Int {
275293 TestCertificate . ca1, TestCertificate . isolatedSelfSignedCertWithWeirdCriticalExtension,
276294 ] )
277295
278- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
296+ var verifier = Verifier ( rootCertificates: roots) {
297+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
298+ }
279299 let result = await verifier. validate (
280- leafCertificate : TestCertificate . isolatedSelfSignedCertWithWeirdCriticalExtension,
300+ leaf : TestCertificate . isolatedSelfSignedCertWithWeirdCriticalExtension,
281301 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
282302 )
283303
@@ -291,9 +311,11 @@ func testWePoliceCriticalExtensionsOnLeafCerts() async -> Int {
291311func testMissingIntermediateFailsToBuild( ) async -> Int {
292312 let roots = CertificateStore ( [ TestCertificate . ca1] )
293313
294- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
314+ var verifier = Verifier ( rootCertificates: roots) {
315+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
316+ }
295317 let result = await verifier. validate (
296- leafCertificate : TestCertificate . localhostLeaf,
318+ leaf : TestCertificate . localhostLeaf,
297319 intermediates: CertificateStore ( [ ] )
298320 )
299321
@@ -307,9 +329,11 @@ func testMissingIntermediateFailsToBuild() async -> Int {
307329func testSelfSignedCertsAreRejectedWhenNotInTheTrustStore( ) async -> Int {
308330 let roots = CertificateStore ( [ TestCertificate . ca1] )
309331
310- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
332+ var verifier = Verifier ( rootCertificates: roots) {
333+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
334+ }
311335 let result = await verifier. validate (
312- leafCertificate : TestCertificate . isolatedSelfSignedCert,
336+ leaf : TestCertificate . isolatedSelfSignedCert,
313337 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
314338 )
315339
@@ -322,9 +346,11 @@ func testSelfSignedCertsAreRejectedWhenNotInTheTrustStore() async -> Int {
322346func testMissingRootFailsToBuild( ) async -> Int {
323347 let roots = CertificateStore ( [ ] )
324348
325- var verifier = Verifier ( rootCertificates: roots) { RFC5280Policy ( validationTime: TestCertificate . referenceTime) }
349+ var verifier = Verifier ( rootCertificates: roots) {
350+ RFC5280Policy ( fixedExpiryValidationTime: TestCertificate . referenceTime)
351+ }
326352 let result = await verifier. validate (
327- leafCertificate : TestCertificate . localhostLeaf,
353+ leaf : TestCertificate . localhostLeaf,
328354 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
329355 )
330356
0 commit comments