1313//===----------------------------------------------------------------------===//
1414
1515import Benchmark
16- import X509
16+ @ _spi ( FixedExpiryValidationTime ) import X509
1717import Foundation
1818import Crypto
1919import SwiftASN1
@@ -50,7 +50,7 @@ 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 (
5656 leaf: TestCertificate . localhostLeaf,
@@ -67,7 +67,9 @@ 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 (
7274 leaf: TestCertificate . localhostLeaf,
7375 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
@@ -83,7 +85,9 @@ 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 (
8892 leaf: TestCertificate . localhostLeaf,
8993 intermediates: CertificateStore ( [ TestCertificate . intermediate1, TestCertificate . ca1, TestCertificate . ca2] )
@@ -99,7 +103,9 @@ 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 (
104110 leaf: TestCertificate . localhostLeaf,
105111 intermediates: CertificateStore ( [ TestCertificate . intermediate1, TestCertificate . ca1CrossSignedByCA2] )
@@ -115,7 +121,9 @@ 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 (
120128 leaf: TestCertificate . localhostLeaf,
121129 intermediates: CertificateStore ( [
@@ -133,7 +141,9 @@ 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 (
138148 leaf: TestCertificate . localhostLeaf,
139149 intermediates: CertificateStore ( [ TestCertificate . intermediate1, TestCertificate . intermediate1WithoutSKIAKI] )
@@ -149,7 +159,9 @@ 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 (
154166 leaf: TestCertificate . localhostLeaf,
155167 intermediates: CertificateStore ( [
@@ -167,7 +179,9 @@ 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 (
172186 leaf: TestCertificate . localhostLeaf,
173187 intermediates: CertificateStore ( [
@@ -186,7 +200,7 @@ 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 (
192206 leaf: TestCertificate . localhostLeaf,
@@ -205,7 +219,9 @@ 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 (
210226 leaf: TestCertificate . isolatedSelfSignedCert,
211227 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
@@ -246,7 +262,9 @@ 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 (
251269 leaf: TestCertificate . localhostLeaf,
252270 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
@@ -275,7 +293,9 @@ 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 (
280300 leaf: TestCertificate . isolatedSelfSignedCertWithWeirdCriticalExtension,
281301 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
@@ -291,7 +311,9 @@ 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 (
296318 leaf: TestCertificate . localhostLeaf,
297319 intermediates: CertificateStore ( [ ] )
@@ -307,7 +329,9 @@ 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 (
312336 leaf: TestCertificate . isolatedSelfSignedCert,
313337 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
@@ -322,7 +346,9 @@ 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 (
327353 leaf: TestCertificate . localhostLeaf,
328354 intermediates: CertificateStore ( [ TestCertificate . intermediate1] )
0 commit comments