keychain

In iOS10, is it possible to access Keychain from within a static library/framework, for unit testing

萝らか妹 提交于 2019-12-04 10:38:24
Until Xcode 8/iOS 10, I was able to access the Keychain from within the unit tests of a static library. After upgrading, I get an error, see stack trace: failed: caught "NSInternalInconsistencyException", "Couldn't add the Keychain Item." ( 0 CoreFoundation 0x000000010b2a734b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010ad0821e objc_exception_throw + 48 2 CoreFoundation 0x000000010b2ab442 +[NSException raise:format:arguments:] + 98 3 Foundation 0x000000010a89eedd -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 MyLibTests 0x0000000117366dea -

iOS: Verifying a File With a Certificate and Signature - Public Key is Wrong, Verification Fails

狂风中的少年 提交于 2019-12-04 10:01:38
问题 I have three things: a file, a signature file, and a X509 certificate file .cer. The file has to be verified using the public key in the certificate and the signature file. I want to do it using Security.h/CommonCrypto. What I tried so far: // load all the files NSData* fileData = [NSData dataWithContentsOfFile:(...)]; NSData* signatureData = [NSData dataWithContentsOfFile:(...)]; NSData* certificateData = [NSData dataWithContentsOfFile:(...)]; SecCertificateRef certificate =

Get the Username(s) stored in Keychain, using only the ServiceName? OR: Where are you supposed to store the Username?

白昼怎懂夜的黑 提交于 2019-12-04 09:21:20
So the OS X Keychain has three pieces of information: ServiceName (the name of my app) Username Password I obviously always know the ServiceName. Is there a way to find any saved Username(s) for that ServiceName? (Finding the password is easy once you know the Username.) I would much prefer to use a nice Cocoa wrapper such as EMKeychain to do this. But EMKeychain requires the UserName to get any keychain item! + (EMGenericKeychainItem *)genericKeychainItemForService:(NSString *)serviceNameString withUsername:(NSString *)usernameString; How are you expected to fully utilize saving credentials

Using SecKeyRawSign on the iPhone

时光总嘲笑我的痴心妄想 提交于 2019-12-04 07:08:04
I'm trying to sign some data using SecKeyRawSign but I keep getting a -4 errSecUnimplemented. That seems strange since the documentation states that it is available in iPhone OS2.0 and later. Has anyone been able to use this function? If so, are there any tricks involved? ~Nate If you're having this problem, most likely it is because the private key you generated isn't actually being saved into the keychain. I figured this out when stopping and restarting the application and signing the message wasn't working. So here are my methods to make this work. This one generates the key pair - (void

Keychain Services API fails with errSecNotAvailable in iphonesimulator 6.0

旧街凉风 提交于 2019-12-04 06:59:43
Calls to the the Keychain Services fail with errSecNotAvailable when executing a target using the command line tools and the iphone simulator is set to Hardware version 6.0 (10A403). If I change the simulator version to other previous version (4.3, 5.0, 5.1) and re-execute using the same command line script the calls succeed. I'm running latest XCode 4.5 and the command line tools were downloaded from within XCode. To reproduce this error just do the following: Setup an ios library project with a OCUnit target Set Base SDK to 6.0 Set iOS Deployment Target to 4.3 Copy and paste the code st the

OpenSSL and Apple Keychain integration

自作多情 提交于 2019-12-04 06:32:11
We're using a multi platform application which should run on both Windows and Mac. Our application is based on OpenSSL as the SSL and related stuff supplier. It uses Client Certificate to establish secure connections and to identify the end user. We want to use Windows and Mac native certificate storages to ensure maximum security. Openssl has an engine to interact with Windows' Certificate Store (CAPI engine). However, we didn't manage to find such a solution for Mac's Keychain. Is there an integration between OpenSSL and Apple's Keychain? If not, what are your suggestion ? In addition to

which key should I use to store the password in iOS keychain?

℡╲_俬逩灬. 提交于 2019-12-04 05:58:01
The KeychainItemWrapper class in the Apple GenericKeychain sample use kSecValueData key to store password. But the reference http://developer.apple.com/library/ios/#documentation/Security/Reference/keychainservices/Reference/reference.html#//apple_ref/doc/uid/TP30000898 says kSecValueData is used in the results dictionary for SecItemCopyMatching or SecItemAdd, indicating the type of values returned. which key should I use when I call SecItemAdd to create a keychain item? You should use kSecValue data as the key to store the password (in NSData or CFDataRef format). The reference is a bit

iOS8 + Apple's KeychainItemWrapper results in a crash

落花浮王杯 提交于 2019-12-04 05:01:22
I've been digging around Apple forums and SO for this issue to no avail. Using Apple's KeychainItemWrapper (ARCified), trying to set the kSecAttrAccessible attribute to anything except the default ( kSecAttrAccessibleWhenUnlocked ) results in an assertion failure from SecItemUpdate returning an error. KeychainItemWrapper *wrapper = [[KeyChainItemWrapper alloc] initWithIdentifier:kMyIdentifier accessGroup:nil]; [wrapper setObject:kMyServiceName forKey:(__bridge NSString*)kSecAttrService]; [wrapper setObject:kMyAccountToken forKey:(__bridge NSString*)kSecAttrAccount]; [wrapper setObject:(_

CLI: Switch keychains in order to sign an xcodebuild

社会主义新天地 提交于 2019-12-04 02:15:35
I am trying to switch on a certain keychain, and close another one. I need this because our enterprise & appstore identities are called the same. Right now, I do a "security unlock-keychain" followed by a "security default-keychain" to open the correct keychain and do a "security lock-keychain" on the keychain I wish not to use. But xcodebuild still sees the entries in both keychains and gives up. iPhone Distribution: Company name.: ambiguous (matches "iPhone Distribution: Company name." in /Users/user/Library/Keychains/login.keychain and "iPhone Distribution: Company name" in /Users/user

KeyChain integration causing crash with “missing entitlement” error — via command line builds

空扰寡人 提交于 2019-12-04 01:54:43
问题 I'm having a problem with some KeyChain code causing archives created via xcodebuild to crash when distributed as ad-hoc apps and run on a device. The problem does not affect builds created via Xcode -- only those created via command line. The code that is throwing the error: (I'm using a KeyChain library found here) KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"myapp" accessGroup:nil]; NSString *testKeychain = (NSString *)[keychain objectForKey:(__bridge