Safari + Keychain

Joined
Mar 2, 2010
Messages
3
Reaction score
0
Points
1
Hi,

I need to build an application that will save some internet passwords in Keychain in order to avoid Safari to prompt them when those sites are browsed.

Do you know how to accomplish it? Adding url in KeyChain is not enough, and I'm not sure how to notify Safari to use an item storage in KeyChain...

Thanks in advance.
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
Hey eddietec welcome.
You shouldnt even have to access keychain ?? I just might not be following your question either

Say im logging into MF for the 1st time, my username then password then click the remember me box, then everytime i log in, i get logged straight in ......

Unless im missing something techie then keychain works great just like that

Cheers
 
OP
E
Joined
Mar 2, 2010
Messages
3
Reaction score
0
Points
1
Hi,

Issue is that I have almost 100 intranets portals that some clients used (because they are not in Active Directory they are prompt to input user+password), we want to use KeyChain to avoid them to input that information for each site. This application will be in charge to add/upgrade logins/passwords for those sites. Problem is that how to add items in keychain in a way Safari can recognize them?

Best regards.
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
Ahh no worries then. Ill admit it is a little over my head lol
Give it time though, someone should be able to come up with the answer your looking for. Good luck with it

Cheers
 
OP
E
Joined
Mar 2, 2010
Messages
3
Reaction score
0
Points
1
Hi,

Here is the answer. Safari sets a property in keychain item that only by code can be set/get. This property is kSecSecurityDomainItemAttr. Following code configures one custom key to make it work with Safari:

Code:
- (void) updateSecKeychainItemRef:(SecKeychainItemRef)item
{    
    SecKeychainAttribute attributes[50];
    SecKeychainAttributeList list;
    OSStatus status;
    
    attributes[0].tag = kSecSecurityDomainItemAttr;
    attributes[0].data = "wwww.portaWithActiveDirectory.com";
    attributes[0].length = strlen("wwww.portaWithActiveDirectory.com");
    list.count = 1;
    
    list.attr = attributes;
    //status = SecKeychainItemModifyContent(item, &list, strlen(PWD), PWD);
    status = SecKeychainItemModifyContent(item, &list, 0, NULL);
    
    if (status == noErr) {
        NSLog(@"\tChanged OK\n");        
    } 
    else {
        NSString *errorMsg = (NSString*) SecCopyErrorMessageString(status, NULL);
        NSLog(@"Error in updateSecKeychainItemRef = %d, %@\n", 
                (int)status, errorMsg);
    }
}

Cheers, Eddie.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top