From 7131bda2e30582d110c674e7184c16f5ad3a205e Mon Sep 17 00:00:00 2001 From: Dwarven Yang Date: Thu, 16 Nov 2017 16:30:21 +0800 Subject: [PATCH] add alert for errSecItemNotFound --- Classes/ApplicationDelegate.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Classes/ApplicationDelegate.m b/Classes/ApplicationDelegate.m index c9fe39d..bae804c 100644 --- a/Classes/ApplicationDelegate.m +++ b/Classes/ApplicationDelegate.m @@ -126,6 +126,13 @@ - (void)connect { // Create identity. result = SecIdentityCreateWithCertificate(_keychainRef, _certificateRef, &_identityRef);// NSLog(@"SecIdentityCreateWithCertificate(): %d", result); + + if (errSecItemNotFound == result) { + NSLog (@"SecIdentityCreateWithCertificate errSecItemNotFound"); + NSAlert * alert = [NSAlert alertWithMessageText:@"Certificates error" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Verify that the local keychain has the corresponding certificates and private keys on your Mac."]; + [alert beginSheetModalForWindow:[[NSApplication sharedApplication] keyWindow] completionHandler:NULL]; + return; + } // Set client certificate. CFArrayRef certificates = CFArrayCreate(NULL, (const void **)&_identityRef, 1, NULL);