keychain

Adding Items to and Querying the iOS Keychain with Swift

*爱你&永不变心* 提交于 2019-11-30 01:47:29
I'm having trouble converting all of the Objective C code samples that are available for adding data and querying data from the iOS Keychain into Swift . I'm trying to do a basic storage of a string (an access token) and reading it back. I've had a look at some of the other questions on Stack Overflow, but I can't quite get it to work. I've tried to piece together a solution from the various sources. Edit 1: I tried with a more basic setup, because I thought my self.defaultKeychainQuery might have been messing things up. I've updated the code below to the latest version. Edit 2: Got it working

Swift keychain and provisioning profiles

只愿长相守 提交于 2019-11-30 01:02:16
We've created an app in swift that uses keychain. The app works fine when run on a device or in the simulator but can't access the keychain when provisioned via Testflight unless provisioned to a new device that's never had the app previously installed via Xcode 6.1. Following is an excerpt of the keychain code: import UIKit import Security let serviceIdentifier = "com.ourdomain" let kSecClassValue = kSecClass as NSString let kSecAttrAccountValue = kSecAttrAccount as NSString let kSecValueDataValue = kSecValueData as NSString let kSecClassGenericPasswordValue = kSecClassGenericPassword as

Reset keychain on the device

南笙酒味 提交于 2019-11-30 00:06:39
问题 I'm testing login flow (using KeychainItemWrapper ) inside my app on a device. How do I reset/delete keychain for my app? On the Simulator, I do it by clicking on iOS Simulator -> Reset Content and Settings... . 回答1: Keychain items are in iOS sandbox, users don't have access to remove unwanted keychain item. These are accessible via API's only. KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:[[NSBundle mainBundle] bundleIdentifier] accessGroup:nil]; //or

Save data in Keychain only accessible with Touch ID in Swift 3

僤鯓⒐⒋嵵緔 提交于 2019-11-29 22:58:07
I'm working on a peace of code that should do the following: Store some data in Keychain. Get the data only if a user authenticates with Touch ID or Pass Code. I watched the Keychain and Authentication with Touch ID presentation and understood the following: If you set the right parameter while adding a new value in to Keychain, next time you'll try to get it out, the system will automatically show the Touch ID popup. I wrote some code, and my assumption doesn't work. This is what I have written: // // Secret value to store // let valueData = "The Top Secret Message V1".data(using: .utf8)!; //

Importing an SSL cert under the iPhone SDK

拜拜、爱过 提交于 2019-11-29 22:40:57
My app connects to the Schwab OFX server using NSURLConnection . Unfortunately the server uses a very recent intermediate certificate that is trusted on the Mac desktop but not yet the iPhone. (Try the URL—you'll get a cert error on iPhone.) There's no easy way to tell NSURLConnection to ignore an invalid cert that I know of. Thus I'm trying to import the cert into the Keychain manually and set its trust level but I've hit a block. I call SecCertificateCreateWithData successfully to import the certificate from a .cer file. On the desktop I would then call SecTrustSettingsSetTrustSettings , but

Store NSDictionary in keychain

元气小坏坏 提交于 2019-11-29 21:47:39
It is possible to store a NSDictionary in the iPhone keychain, using KeychainItemWrapper (or without)? If it's not possible, have you another solution? Bret Deasy You must properly serialize the NSDictionary before storing it into the Keychain. Using: [dic description] [dic propertyList] you will end up with a NSDictionary collection of only NSString objects. If you want to maintain the data types of the objects, you can use NSPropertyListSerialization . KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"arbitraryId" accessGroup:nil] NSString *error; //The

I lost my public key. Can I recover it from a private key?

落爺英雄遲暮 提交于 2019-11-29 20:29:08
I created a key pair + signed certificate for iOS/OSX development. Somewhere along the way, I lost the public key that goes with my private key. Maybe it's because Keychain Access doesn't group the private and public keys together, like it does with certificates and private keys (that is so irritating! why does it (not) do that!) In Keychain Access, I can still right-click the private key -> "Request a certificate"; but without the public key available I get the error "The specified item could not be found in the keychain". I am pretty sure that public keys are recoverable, but how? Obviously,

Slow app compilation with new Sierra update

纵饮孤独 提交于 2019-11-29 20:21:53
When I updated my mac to macOS Sierra 10.12.1 time of running application on real device significantly increased. "Run custom script 'Embed Pods Frameworks'" and "Copy Swift standard libraries" take more then 30 minutes to build. Do someone face the same issue? Check your keychain. After updating to Sierra to 10.12.1, I had over 500 copies one of my certificates, and a few others were duplicated a few hundred times. I removed all the duplicates and kept just one of each, and my code signing time went from 30 seconds per framework down to about 1 second per. I don't know how or why the

Error saving in the keychain with iphone sdk

守給你的承諾、 提交于 2019-11-29 20:11:22
I use the Apple wraper for the keychain , and try to save a item on it (running in simulator, ios 4.1). I have not experience with the keychain before. I get this error: Couldn't add the Keychain Item. Error - 25299 In KeychainItemWrapper.m line 304: // No previous item found; add the new one. result = SecItemAdd((CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL); NSAssert( result == noErr, @"Couldn't add the Keychain Item." ); This is how I do the save: - (void) saveKey:(NSString *)key value:(NSString *)value { KeychainItemWrapper *keyItem = [[KeychainItemWrapper alloc]

iOS SFHFKeychainUtils failing *sometimes* with error -25308 errSecInteractionNotAllowed

痴心易碎 提交于 2019-11-29 19:45:12
I have this code getting back a password from the keychain for a given username NSString: NSError *error = nil; NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]; NSString *pw = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:appName error:&error]; if(error != nil) // log the error Most of the time for most users this all works fine - but for some specific users this call seems to fail (and carry on failing) where it returns the following error: The operation couldn’t be completed. (SFHFKeychainUtilsErrorDomain error -25308.