Skip to content

How to fix "MissingEntitlement: SecKeychainItemCopyContent refused to return data"? #22

@hktonylee

Description

@hktonylee

I tried to run the following program but it panic with: "Error { kind: MissingEntitlement, backtrace: , description: "SecKeychainItemCopyContent refused to return data" }"

extern crate keychain_services;

use keychain_services::{Keychain, keychain};

fn main() {
    println!("Getting keychain...");
    if let Ok(default_keychain) = Keychain::find_default() {
        println!("Getting password...");
        if let Ok(generic_password)
            = keychain::item::GenericPassword::find(&default_keychain, "TestTest", "user") {
            println!("Printing password...");
            println!("Password: {}", generic_password.password().unwrap().as_str())
        }
    }
}

I tried codesign as instructed in the Apple Developer guide. I created a self-signed certificate. Then I used gimmedebugah to inject Info.plist to the binary. Lastly I run the codesign using the self-signed certificate. I can verify the app is correctly signed with the following command

> codesign --verify --deep --strict --verbose=2 my_app
my_app: valid on disk
my_app: satisfies its Designated Requirement

In the Info.plist injection step, I also tried to linker flag -sectcreate __TEXT __info_plist Info.plist -o my_app.out to the .cargo/config.

But the app still cannot retrieve password from keychain. Now I have no clue what to do next. Would you mind sharing any step-by-step guideline? It will be very useful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions