Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
两个共享钥匙链数据的应用程序在iOS模拟器中运行良好,但在设备中不起作用_Ios_Keychain_Security Framework - Fatal编程技术网

两个共享钥匙链数据的应用程序在iOS模拟器中运行良好,但在设备中不起作用

两个共享钥匙链数据的应用程序在iOS模拟器中运行良好,但在设备中不起作用,ios,keychain,security-framework,Ios,Keychain,Security Framework,我试图从另一个具有相同标识符(相同配置文件)的应用程序访问应用程序设置的密钥链数据。我曾经做到过这一点 钥匙链数据的保存正确,我在下面的语句中获得了errSecSuccess(在模拟器和设备中) 到目前为止还不错,但当我试图取回我的应用程序A保存在另一个应用程序B中的凭据时,它在模拟器和设备中的工作方式不同 在iOS simulator 6.1中,以下语句的状态为“0” OSStatus status = SecItemCopyMatching((CFDictionaryRef)searchD

我试图从另一个具有相同标识符(相同配置文件)的应用程序访问应用程序设置的密钥链数据。我曾经做到过这一点

钥匙链数据的保存正确,我在下面的语句中获得了errSecSuccess(在模拟器和设备中)

到目前为止还不错,但当我试图取回我的应用程序A保存在另一个应用程序B中的凭据时,它在模拟器和设备中的工作方式不同

在iOS simulator 6.1中,以下语句的状态为“0”

 OSStatus status = SecItemCopyMatching((CFDictionaryRef)searchDictionary, &foundDict);
在任何iOS设备中,我的状态都是“-25300”

我知道这些是安全框架中的错误代码:

//errSecSuccess                = 0,       /* No error. */
//errSecUnimplemented          = -4,      /* Function or operation not implemented. */
//errSecParam                  = -50,     /* One or more parameters passed to a function where not valid. */
//errSecAllocate               = -108,    /* Failed to allocate memory. */
//errSecNotAvailable           = -25291,  /* No keychain is available. You may need to restart your computer. */
//errSecDuplicateItem          = -25299,  /* The specified item already exists in the keychain. */
//errSecItemNotFound           = -25300,  /* The specified item could not be found in the keychain. */
//errSecInteractionNotAllowed  = -25308,  /* User interaction is not allowed. */
//errSecDecode                 = -26275,  /* Unable to decode the provided data. */
//errSecAuthFailed             = -25293,  /* The user name or passphrase you entered is not correct. */

我明白了,这个项目没有找到,但为什么不同的设备和模拟器

据我所知,默认情况下,您在应用程序中处理的钥匙链组不会在系统上的其他应用程序之间共享。如果是这种情况,这将意味着如果你设法找到另一个应用程序的组,你可能会窃取他们的私人密钥链项目,从而使密钥链提供的安全性失效

因此,有一个被称为“钥匙链访问组”的概念,允许公开定义您希望在应用程序中共享的钥匙链组。各国:

启用密钥链共享允许您的应用程序在中共享密码 钥匙链与您团队开发的其他应用程序


因此,请注意,您只能与来自同一开发人员的其他应用程序(即您的其他应用程序)共享钥匙链项目。

添加到此答案。我遇到了同样的问题。在模拟器中,似乎不需要设置钥匙链访问组。只要在
kSecAttrAccessGroup
属性中使用相同的组ID就足够了。然而,这在真正的设备上不起作用。必须正确设置权限,才能使钥匙链访问组在设备上工作。这在测试时咬了我一口,因为我没有在真正的设备上测试,而且组名中有一个输入错误。@stuckj我在使用钥匙链共享时遇到了问题。你们能看看这个问题吗:嗨,我在应用程序扩展中使用钥匙链访问面临问题。在模拟器上工作,但在设备上不工作。这是针对同一问题提出的问题:。如果可能的话,请调查一下,谢谢。
//errSecSuccess                = 0,       /* No error. */
//errSecUnimplemented          = -4,      /* Function or operation not implemented. */
//errSecParam                  = -50,     /* One or more parameters passed to a function where not valid. */
//errSecAllocate               = -108,    /* Failed to allocate memory. */
//errSecNotAvailable           = -25291,  /* No keychain is available. You may need to restart your computer. */
//errSecDuplicateItem          = -25299,  /* The specified item already exists in the keychain. */
//errSecItemNotFound           = -25300,  /* The specified item could not be found in the keychain. */
//errSecInteractionNotAllowed  = -25308,  /* User interaction is not allowed. */
//errSecDecode                 = -26275,  /* Unable to decode the provided data. */
//errSecAuthFailed             = -25293,  /* The user name or passphrase you entered is not correct. */