iOS Keychain - LAContext.setCredential(data, .applicationPassword) returns false on Simulator





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to use an "applicationPassword" to protect the data that a user stores in the Keychain.



Everything works perfectly on a real device but unfortunately things don't work at all on the simulator.



In order to get started I have this very basic code to set the applicationPassword.



let authenticationContext = LAContext()
let applicationPassword = "123".data(using: .utf8)
let result = authenticationContext.setCredential(applicationPassword, type: .applicationPassword)
print(result)


The call to setCredential returns true on a real device but false on the simulator.



Please help :-)



If this isn't supported on the Simulator then it isn't really a feasible solution.



Here is Apple's documentation, for reference:



https://developer.apple.com/documentation/localauthentication/lacontext/1514168-setcredential










share|improve this question

























  • On the simulator make sure you are enrolled in faceId/TouchId under Hardware menu

    – Woodstock
    Nov 16 '18 at 16:20











  • Thanks for the reply. setCredential has nothing to do with biometrics (faceID or touchID) so I wouldn't have expected this to make a difference. I have tried as suggested and the call still returns false.

    – Oliver Pearmain
    Nov 16 '18 at 16:28











  • On simulator it will not work properly, had same issue

    – canister_exister
    Nov 16 '18 at 17:15


















0















I am trying to use an "applicationPassword" to protect the data that a user stores in the Keychain.



Everything works perfectly on a real device but unfortunately things don't work at all on the simulator.



In order to get started I have this very basic code to set the applicationPassword.



let authenticationContext = LAContext()
let applicationPassword = "123".data(using: .utf8)
let result = authenticationContext.setCredential(applicationPassword, type: .applicationPassword)
print(result)


The call to setCredential returns true on a real device but false on the simulator.



Please help :-)



If this isn't supported on the Simulator then it isn't really a feasible solution.



Here is Apple's documentation, for reference:



https://developer.apple.com/documentation/localauthentication/lacontext/1514168-setcredential










share|improve this question

























  • On the simulator make sure you are enrolled in faceId/TouchId under Hardware menu

    – Woodstock
    Nov 16 '18 at 16:20











  • Thanks for the reply. setCredential has nothing to do with biometrics (faceID or touchID) so I wouldn't have expected this to make a difference. I have tried as suggested and the call still returns false.

    – Oliver Pearmain
    Nov 16 '18 at 16:28











  • On simulator it will not work properly, had same issue

    – canister_exister
    Nov 16 '18 at 17:15














0












0








0








I am trying to use an "applicationPassword" to protect the data that a user stores in the Keychain.



Everything works perfectly on a real device but unfortunately things don't work at all on the simulator.



In order to get started I have this very basic code to set the applicationPassword.



let authenticationContext = LAContext()
let applicationPassword = "123".data(using: .utf8)
let result = authenticationContext.setCredential(applicationPassword, type: .applicationPassword)
print(result)


The call to setCredential returns true on a real device but false on the simulator.



Please help :-)



If this isn't supported on the Simulator then it isn't really a feasible solution.



Here is Apple's documentation, for reference:



https://developer.apple.com/documentation/localauthentication/lacontext/1514168-setcredential










share|improve this question
















I am trying to use an "applicationPassword" to protect the data that a user stores in the Keychain.



Everything works perfectly on a real device but unfortunately things don't work at all on the simulator.



In order to get started I have this very basic code to set the applicationPassword.



let authenticationContext = LAContext()
let applicationPassword = "123".data(using: .utf8)
let result = authenticationContext.setCredential(applicationPassword, type: .applicationPassword)
print(result)


The call to setCredential returns true on a real device but false on the simulator.



Please help :-)



If this isn't supported on the Simulator then it isn't really a feasible solution.



Here is Apple's documentation, for reference:



https://developer.apple.com/documentation/localauthentication/lacontext/1514168-setcredential







ios swift keychain






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 16:44







Oliver Pearmain

















asked Nov 16 '18 at 15:50









Oliver PearmainOliver Pearmain

11.2k86669




11.2k86669













  • On the simulator make sure you are enrolled in faceId/TouchId under Hardware menu

    – Woodstock
    Nov 16 '18 at 16:20











  • Thanks for the reply. setCredential has nothing to do with biometrics (faceID or touchID) so I wouldn't have expected this to make a difference. I have tried as suggested and the call still returns false.

    – Oliver Pearmain
    Nov 16 '18 at 16:28











  • On simulator it will not work properly, had same issue

    – canister_exister
    Nov 16 '18 at 17:15



















  • On the simulator make sure you are enrolled in faceId/TouchId under Hardware menu

    – Woodstock
    Nov 16 '18 at 16:20











  • Thanks for the reply. setCredential has nothing to do with biometrics (faceID or touchID) so I wouldn't have expected this to make a difference. I have tried as suggested and the call still returns false.

    – Oliver Pearmain
    Nov 16 '18 at 16:28











  • On simulator it will not work properly, had same issue

    – canister_exister
    Nov 16 '18 at 17:15

















On the simulator make sure you are enrolled in faceId/TouchId under Hardware menu

– Woodstock
Nov 16 '18 at 16:20





On the simulator make sure you are enrolled in faceId/TouchId under Hardware menu

– Woodstock
Nov 16 '18 at 16:20













Thanks for the reply. setCredential has nothing to do with biometrics (faceID or touchID) so I wouldn't have expected this to make a difference. I have tried as suggested and the call still returns false.

– Oliver Pearmain
Nov 16 '18 at 16:28





Thanks for the reply. setCredential has nothing to do with biometrics (faceID or touchID) so I wouldn't have expected this to make a difference. I have tried as suggested and the call still returns false.

– Oliver Pearmain
Nov 16 '18 at 16:28













On simulator it will not work properly, had same issue

– canister_exister
Nov 16 '18 at 17:15





On simulator it will not work properly, had same issue

– canister_exister
Nov 16 '18 at 17:15












1 Answer
1






active

oldest

votes


















0














It would seem that applicationPassword works in conjunction with the device's system passcode.



And therefore an applicationPassword will NOT work on:




  • The simulator (where its not possible to set a system passcode)

  • A real device without a system passcode set


I have ascertained this information from the below souces:





WWDC 2015 - Session 706 - Security & Your Apps (see around 43:23 of video)



Transcript: https://asciiwwdc.com/2015/sessions/706?q=applicationpassword




Now, let's look at an item protected with ApplicationPassword.



Just the device passcode is no longer sufficient.



Your application has also got to provide its own password.



Again, we derive a cryptographic key from it, and it's only when the
device passcode and the app password are both present that access is
granted to the Keychain item.






https://nabla-c0d3.github.io/blog/2015/06/16/ios9-security-privacy/




Keychain items can now be encrypted using both the device’s passcode
and an “Application password”; both values are then needed to decrypt
and retrieve the item. This allows Apps to control when the data is
accessible/decrypted, instead of having the data decrypted as soon as
the device is unlocked.






https://macbirdie.net/2016/03/app-pwd




The other interesting new feature is securing the keychain items using
an application-provided password, which is an additional factor to
device unlock PIN or passcode.



The password can either come from the user or, as the session 706’s
presenter suggested, either can be an additional token sent by the
server or a secret kept on a device connected to the phone.



This security scheme requires at least a device passcode to exist,
since it works with it in tandem. As a result of that it’s not
possible to test it on the iOS Simulator, which makes developing the
support for it a little harder, because when you add a keychain item
protected that way, no actual password is even required to retrieve
it.






Its a shame that none of Apple's own documention seems to make a mention of this:




  • Apple - setCredential(_:type:)

  • Apple - LACredentialType.applicationPassword

  • Apple - applicationPassword

  • Apple - Restricting Keychain Item Accessibility






share|improve this answer
























  • Hmm, for me it works perfectly fine on a real device with passcode turned off.

    – algrid
    Apr 1 at 15:32












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341248%2fios-keychain-lacontext-setcredentialdata-applicationpassword-returns-false%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














It would seem that applicationPassword works in conjunction with the device's system passcode.



And therefore an applicationPassword will NOT work on:




  • The simulator (where its not possible to set a system passcode)

  • A real device without a system passcode set


I have ascertained this information from the below souces:





WWDC 2015 - Session 706 - Security & Your Apps (see around 43:23 of video)



Transcript: https://asciiwwdc.com/2015/sessions/706?q=applicationpassword




Now, let's look at an item protected with ApplicationPassword.



Just the device passcode is no longer sufficient.



Your application has also got to provide its own password.



Again, we derive a cryptographic key from it, and it's only when the
device passcode and the app password are both present that access is
granted to the Keychain item.






https://nabla-c0d3.github.io/blog/2015/06/16/ios9-security-privacy/




Keychain items can now be encrypted using both the device’s passcode
and an “Application password”; both values are then needed to decrypt
and retrieve the item. This allows Apps to control when the data is
accessible/decrypted, instead of having the data decrypted as soon as
the device is unlocked.






https://macbirdie.net/2016/03/app-pwd




The other interesting new feature is securing the keychain items using
an application-provided password, which is an additional factor to
device unlock PIN or passcode.



The password can either come from the user or, as the session 706’s
presenter suggested, either can be an additional token sent by the
server or a secret kept on a device connected to the phone.



This security scheme requires at least a device passcode to exist,
since it works with it in tandem. As a result of that it’s not
possible to test it on the iOS Simulator, which makes developing the
support for it a little harder, because when you add a keychain item
protected that way, no actual password is even required to retrieve
it.






Its a shame that none of Apple's own documention seems to make a mention of this:




  • Apple - setCredential(_:type:)

  • Apple - LACredentialType.applicationPassword

  • Apple - applicationPassword

  • Apple - Restricting Keychain Item Accessibility






share|improve this answer
























  • Hmm, for me it works perfectly fine on a real device with passcode turned off.

    – algrid
    Apr 1 at 15:32
















0














It would seem that applicationPassword works in conjunction with the device's system passcode.



And therefore an applicationPassword will NOT work on:




  • The simulator (where its not possible to set a system passcode)

  • A real device without a system passcode set


I have ascertained this information from the below souces:





WWDC 2015 - Session 706 - Security & Your Apps (see around 43:23 of video)



Transcript: https://asciiwwdc.com/2015/sessions/706?q=applicationpassword




Now, let's look at an item protected with ApplicationPassword.



Just the device passcode is no longer sufficient.



Your application has also got to provide its own password.



Again, we derive a cryptographic key from it, and it's only when the
device passcode and the app password are both present that access is
granted to the Keychain item.






https://nabla-c0d3.github.io/blog/2015/06/16/ios9-security-privacy/




Keychain items can now be encrypted using both the device’s passcode
and an “Application password”; both values are then needed to decrypt
and retrieve the item. This allows Apps to control when the data is
accessible/decrypted, instead of having the data decrypted as soon as
the device is unlocked.






https://macbirdie.net/2016/03/app-pwd




The other interesting new feature is securing the keychain items using
an application-provided password, which is an additional factor to
device unlock PIN or passcode.



The password can either come from the user or, as the session 706’s
presenter suggested, either can be an additional token sent by the
server or a secret kept on a device connected to the phone.



This security scheme requires at least a device passcode to exist,
since it works with it in tandem. As a result of that it’s not
possible to test it on the iOS Simulator, which makes developing the
support for it a little harder, because when you add a keychain item
protected that way, no actual password is even required to retrieve
it.






Its a shame that none of Apple's own documention seems to make a mention of this:




  • Apple - setCredential(_:type:)

  • Apple - LACredentialType.applicationPassword

  • Apple - applicationPassword

  • Apple - Restricting Keychain Item Accessibility






share|improve this answer
























  • Hmm, for me it works perfectly fine on a real device with passcode turned off.

    – algrid
    Apr 1 at 15:32














0












0








0







It would seem that applicationPassword works in conjunction with the device's system passcode.



And therefore an applicationPassword will NOT work on:




  • The simulator (where its not possible to set a system passcode)

  • A real device without a system passcode set


I have ascertained this information from the below souces:





WWDC 2015 - Session 706 - Security & Your Apps (see around 43:23 of video)



Transcript: https://asciiwwdc.com/2015/sessions/706?q=applicationpassword




Now, let's look at an item protected with ApplicationPassword.



Just the device passcode is no longer sufficient.



Your application has also got to provide its own password.



Again, we derive a cryptographic key from it, and it's only when the
device passcode and the app password are both present that access is
granted to the Keychain item.






https://nabla-c0d3.github.io/blog/2015/06/16/ios9-security-privacy/




Keychain items can now be encrypted using both the device’s passcode
and an “Application password”; both values are then needed to decrypt
and retrieve the item. This allows Apps to control when the data is
accessible/decrypted, instead of having the data decrypted as soon as
the device is unlocked.






https://macbirdie.net/2016/03/app-pwd




The other interesting new feature is securing the keychain items using
an application-provided password, which is an additional factor to
device unlock PIN or passcode.



The password can either come from the user or, as the session 706’s
presenter suggested, either can be an additional token sent by the
server or a secret kept on a device connected to the phone.



This security scheme requires at least a device passcode to exist,
since it works with it in tandem. As a result of that it’s not
possible to test it on the iOS Simulator, which makes developing the
support for it a little harder, because when you add a keychain item
protected that way, no actual password is even required to retrieve
it.






Its a shame that none of Apple's own documention seems to make a mention of this:




  • Apple - setCredential(_:type:)

  • Apple - LACredentialType.applicationPassword

  • Apple - applicationPassword

  • Apple - Restricting Keychain Item Accessibility






share|improve this answer













It would seem that applicationPassword works in conjunction with the device's system passcode.



And therefore an applicationPassword will NOT work on:




  • The simulator (where its not possible to set a system passcode)

  • A real device without a system passcode set


I have ascertained this information from the below souces:





WWDC 2015 - Session 706 - Security & Your Apps (see around 43:23 of video)



Transcript: https://asciiwwdc.com/2015/sessions/706?q=applicationpassword




Now, let's look at an item protected with ApplicationPassword.



Just the device passcode is no longer sufficient.



Your application has also got to provide its own password.



Again, we derive a cryptographic key from it, and it's only when the
device passcode and the app password are both present that access is
granted to the Keychain item.






https://nabla-c0d3.github.io/blog/2015/06/16/ios9-security-privacy/




Keychain items can now be encrypted using both the device’s passcode
and an “Application password”; both values are then needed to decrypt
and retrieve the item. This allows Apps to control when the data is
accessible/decrypted, instead of having the data decrypted as soon as
the device is unlocked.






https://macbirdie.net/2016/03/app-pwd




The other interesting new feature is securing the keychain items using
an application-provided password, which is an additional factor to
device unlock PIN or passcode.



The password can either come from the user or, as the session 706’s
presenter suggested, either can be an additional token sent by the
server or a secret kept on a device connected to the phone.



This security scheme requires at least a device passcode to exist,
since it works with it in tandem. As a result of that it’s not
possible to test it on the iOS Simulator, which makes developing the
support for it a little harder, because when you add a keychain item
protected that way, no actual password is even required to retrieve
it.






Its a shame that none of Apple's own documention seems to make a mention of this:




  • Apple - setCredential(_:type:)

  • Apple - LACredentialType.applicationPassword

  • Apple - applicationPassword

  • Apple - Restricting Keychain Item Accessibility







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 '18 at 11:02









Oliver PearmainOliver Pearmain

11.2k86669




11.2k86669













  • Hmm, for me it works perfectly fine on a real device with passcode turned off.

    – algrid
    Apr 1 at 15:32



















  • Hmm, for me it works perfectly fine on a real device with passcode turned off.

    – algrid
    Apr 1 at 15:32

















Hmm, for me it works perfectly fine on a real device with passcode turned off.

– algrid
Apr 1 at 15:32





Hmm, for me it works perfectly fine on a real device with passcode turned off.

– algrid
Apr 1 at 15:32




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341248%2fios-keychain-lacontext-setcredentialdata-applicationpassword-returns-false%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine