File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -522,6 +522,20 @@ - (void) testCreateIdentityWithNoAttributes {
522522 Assert ([error.localizedDescription containsString: @" -67655" ]);
523523}
524524
525+ - (void ) testCertificateExpirationAlreadyPast {
526+ XCTSkipUnless (self.keyChainAccessAllowed );
527+ NSDate * expired = [NSDate distantPast ];
528+
529+ [self expectException: @" NSInvalidArgumentException" in: ^{
530+ NSError * error;
531+ [CBLTLSIdentity createIdentityForKeyUsages: kCBLKeyUsagesServerAuth
532+ attributes: kServerCertAttrs
533+ expiration: expired
534+ label: kServerCertLabel
535+ error: &error];
536+ }];
537+ }
538+
525539- (void ) testCertificateExpiration {
526540 XCTSkipUnless (self.keyChainAccessAllowed );
527541
Original file line number Diff line number Diff line change @@ -412,6 +412,21 @@ class TLSIdentityTest: CBLTestCase {
412412 }
413413 }
414414
415+ func testCertificateExpirationAlreadyPast( ) throws {
416+ try XCTSkipUnless ( keyChainAccessAllowed)
417+
418+ // A date definitely in the past
419+ let expired = Date . distantPast
420+
421+ expectException ( exception: . invalidArgumentException) {
422+ _ = try ? TLSIdentity . createIdentity (
423+ for: . serverAuth,
424+ attributes: [ certAttrCommonName: " CBL-Server " ] ,
425+ expiration: expired,
426+ label: self . serverCertLabel)
427+ }
428+ }
429+
415430 func testCertificateExpiration( ) throws {
416431 try XCTSkipUnless ( keyChainAccessAllowed)
417432
You can’t perform that action at this time.
0 commit comments