Bug 44361 - SecKeyChain.Remove(query) returns code -34018
Summary: SecKeyChain.Remove(query) returns code -34018
Status: RESOLVED UPSTREAM
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- critical
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
: 44442 44988 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-09-15 11:07 UTC by FieldstrikeMobile
Modified: 2016-10-03 20:51 UTC (History)
6 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description FieldstrikeMobile 2016-09-15 11:07:49 UTC
# Steps to reproduce
I have written my own method but the exact same method is used in Xamarin.Auth, I am trying to remove values from the keychain:

        public void DeleteAccounts()
        {
            foreach (var service in Services)
            {
                var query = new SecRecord(SecKind.GenericPassword);
                query.Service = CreateAlias(service);

                var statusCode = SecKeyChain.Remove(query);
            }
        }

but SecKeyChain.Remove(query) returns the code -34018. I dont know whether this is related to Xcode 8 upgrade or Visual Studio Extension V4.2

I am running using Visual Studio 2015 Update 3 on Windows and Xcode 8 on Mac OSx
Comment 1 FieldstrikeMobile 2016-09-15 11:10:04 UTC
I am running on Ipad Air 2 IOS 10 simulator
Comment 2 Sebastien Pouliot 2016-09-15 12:23:35 UTC
This is an known issue with Apple's simulator (affects everyone, not just XI).

https://developer.xamarin.com/releases/ios/xamarin.ios_10/xamarin.ios_10.0/#Upstream_Issues_in_Xcode

A workaround was shared in https://bugzilla.xamarin.com/show_bug.cgi?id=43514#c11

*** This bug has been marked as a duplicate of bug 43514 ***
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2016-09-19 21:14:13 UTC
I will change the resolution on this bug from "duplicate" to "upstream" to account for the way that Bug 43514 ended up getting used to track a fix in a sample project rather than being marked as an upstream issue.


In further study of the workaround, I found that it was not in fact necessary to enable "Keychain Access Groups" in the Entitlements.plist file.  It was sufficient just to add _any_ Entitlements.plist file (even one with no property keys).




## Workaround in Xamarin Studio on Mac


1. Add an "iOS > Property List" to the project and name it "Entitlements.plist".


2. Add the "Entitlements.plist" file under "Project Options > Build > iOS Bundle Signing > Custom Entitlements".

(Be sure to follow step 5 for the "iPhoneSimulator" configuration, and not just the "iPhone" configuration.)


3. Save the project properties and re-deploy the app to the simulator.




## Workaround in Visual Studio


1. Add a new "Apple > Misc > Entitlements.plist" file to the top level of the project.


2. Enter the text the "Entitlements.plist" file under "Project properties > iOS Bundle Signing > Custom Entitlements".  **Important**: Do not use the file browser "..." dialog for this step.  I have found a critical bug with that selector in this scenario where it deletes the "Entitlements.plist" file from disk rather than selecting it.  I will file a follow-up bug for that immediately and reply back with the bug number for tracking.

(Be sure to follow step 2 for the "iPhoneSimulator" configuration, and not just the "iPhone" configuration.)


3. Save the project properties and re-deploy the app to the simulator.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2016-09-19 23:53:43 UTC
I have now filed the follow-up critical bug about Xamarin for Visual Studio's "Custom entitlements" file browser dialog under Bug 44508.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2016-09-20 20:25:15 UTC
*** Bug 44442 has been marked as a duplicate of this bug. ***
Comment 6 Timothy Risi 2016-10-03 20:51:46 UTC
*** Bug 44988 has been marked as a duplicate of this bug. ***

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Note You need to log in before you can comment on or make changes to this bug.