locked
IOS 10 keychain RRS feed

  • Question

  • User126277 posted

    HI All,

    I have the following code

            var s = new SecRecord(SecKind.GenericPassword)
            {
                ValueData = NSData.FromString(key),
                Account = Convert.ToString(NSData.FromString(account)),
                Generic = NSData.FromString(key)
            };
            var err = SecKeyChain.Add(s);
            if (err != SecStatusCode.Success && err != SecStatusCode.DuplicateItem)
            {
                Console.WriteLine(err);
                //DisplayMessage ("Error adding record: {0}", err);
            }
    

    where key is "login-credentials" account is the user mail and value is the password.

    However I am getting the following error message -34018 on the variable "err" after I do this: var err = SecKeyChain.Add(s);

    anyone has any idea on whats going on?

    This used to work but now it doesn't in IOS 10.

    Thursday, September 15, 2016 8:27 PM

All replies

  • User13824 posted

    See the Xamarin.iOS 10.0 release notes:

    Upstream Issues (in Xcode)

    Thursday, September 15, 2016 9:02 PM
  • User126277 posted

    Thank you!

    Tuesday, September 20, 2016 2:26 PM
  • User192 posted

    See also https://bugzilla.xamarin.com/show_bug.cgi?id=43514

    Tuesday, September 20, 2016 11:36 PM
  • User40995 posted

    @GerryHigh would like to see that bug, but it's not public :neutral:

    Friday, October 7, 2016 11:30 PM
  • User40995 posted

    @BrendanZagaeski Enabling keychain access groups did not work for me, nor did adding a basic Entitlements.plist.

    Friday, October 7, 2016 11:47 PM
  • User13824 posted

    [from the latest text of the release notes]: (Xamarin tracking bug with more details on how to add an Entitlements.plist: 44361.)

    Saturday, October 8, 2016 1:48 AM
  • User192 posted

    @KentBoogaart I'm not sure why they marked that as Xamarin Private as there was nothing in it that would have made it private.

    Saturday, October 8, 2016 2:37 PM
  • User13824 posted

    I marked Bug 43514 to direct future users who might search for the error in Bugzilla toward Bug 44361 instead. The trouble was that unfortunately the engineering team ended up using Bug 43514 to track a specific fix for the Xamarin sample projects rather than leaving it as a general upstream tracking bug. So for example, the resolution and verification status on that bug misleadingly made it look like Xamarin had fixed something that would stop the problem for all users who were upgrading, but that is not the case: Xamarin only changed one particular sample in that bug report. Users will still need to adjust their own projects by hand.

    That particular scenario (having a general upstream bug be overtaken by a fix for one particular sample) is a bit unusual. So I weighed the situation as its own unique case and eventually decided to take a correspondingly unusual approach of enabling the privacy setting due to the technical constraints of Xamarin's Bugzilla privacy, editing, and information presentation features. In the absence of those technical constraints, marking the bug private would not have been my first choice.

    (In theory, if the engineering team had had a standard policy of opening separate bug reports to track fixes in the individual sample projects for upstream changes, then they would have opened a new bug specifically for the sample fix and that would have avoided the complication. But again, unfortunately this scenario has not come up often enough to date for that kind of usage pattern to have become a policy. I will record this example for consideration in future internal discussions of Bugzilla usage patterns.)

    Saturday, October 8, 2016 5:27 PM
  • User159623 posted

    This answer on StackOverflow helped me: http://stackoverflow.com/a/39576798/5953643

    I forgot to add Entitlements.plist to my iOS Bundle Signing options for the iPhoneSimulator platform

    Wednesday, March 15, 2017 5:45 PM
  • User123891 posted

    Thanks for the tip @BrandonMinnick but when I add the Entitlements.plist as you describe I got the following error instead: "No installed provisioning profiles match the installed iOS signing identities”. Do you have any solution for that?

    Tuesday, April 11, 2017 8:02 AM
  • User123891 posted

    Finally found a solution here: http://stackoverflow.com/a/40249263/2366321

    Do not add Entitlements.plist to your Debug iPhoneSimulator configuration, instead: Add an Environment Variable to your Debug iPhoneSimulator configuration named ENTITLEMENTS_REQUIRED and set the value to YES. This will cause Xcode to automatically insert an application-identifier entitlement when building.

    Tuesday, April 11, 2017 12:45 PM
  • User299549 posted

    @TorbjrnRosendahl said: Finally found a solution here: http://stackoverflow.com/a/40249263/2366321

    Do not add Entitlements.plist to your Debug iPhoneSimulator configuration, instead: Add an Environment Variable to your Debug iPhoneSimulator configuration named ENTITLEMENTS_REQUIRED and set the value to YES. This will cause Xcode to automatically insert an application-identifier entitlement when building.

    Where do you go to add this environment variable to your configuration?

    Sunday, April 30, 2017 11:11 PM
  • User123891 posted

    @Programmer17 - Right click on your iOS project in Visual Studio and select properties, then click the "iOS Run Options" tab. There you will find "Environment Variables:"

    Unfortunately, it only seems to work with Xcode 8.1. I have now upgraded to Xcode 8.3.2 and then this workaround does not seem to work anymore.

    Tuesday, May 2, 2017 6:09 AM
  • User299549 posted

    Thank you @TorbjrnRosendahl.

    Is this a known bug? Surely there must be a fix for this somewhere for 8.3.2 (the latest xcode version)

    Tuesday, May 2, 2017 1:19 PM
  • User123891 posted

    It seems to be a known bug/breaking change @Programmer17 (https://forums.developer.apple.com/thread/62847 and https://forums.developer.apple.com/thread/60617 for example)

    However, I managed to get around the problem (again :smile:) by generating a new developer provisioning profile (the current one had expired) and then adding Entitlement.plist to the Debug IPhoneSimulator configuration as described above.

    Tuesday, May 16, 2017 9:14 PM
  • User54696 posted

    @TorbjrnRosendahl said: Thanks for the tip @BrandonMinnick but when I add the Entitlements.plist as you describe I got the following error instead: "No installed provisioning profiles match the installed iOS signing identities”. Do you have any solution for that?

    @BrandonMinnick said: This answer on StackOverflow helped me: http://stackoverflow.com/a/39576798/5953643

    I forgot to add Entitlements.plist to my iOS Bundle Signing options for the iPhoneSimulator platform

    YOUR GREAT!!! THANKS A LOT

    Wednesday, November 13, 2019 2:54 PM