Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Get Private Key of Identity #2

Open
qbasicer opened this issue Jan 27, 2015 · 1 comment
Open

Cannot Get Private Key of Identity #2

qbasicer opened this issue Jan 27, 2015 · 1 comment

Comments

@qbasicer
Copy link

If I enumerate the identities available like:

v = Keychain::Scope.new(Sec::Classes::IDENTITY)

v.all.each{|identity|
    if (this_is_the_cert) then
        identity.private_key.export("", :kSecFormatPEMSequence
    end
end

The export here generates:

[...]/ruby-keychain-0.1.2/lib/keychain/sec.rb:191:in `check_osstatus': The contents of this item cannot be retrieved. (-25316) (Keychain::Error)

Oddly, if I enumerate keys (Sec::Classes::KEY), then I can export it. In my Keychain Access, I see the certificate (under My Certificates), with an expand error that shows my key. That key has a label (I'm not sure where this comes from). In keys, there's an expand arrow that shows my certificate.

I cannot figure out how to get a private key from a given certificate (and vice versa). I could go through all the keys and export them and compare the public keys to the certificate's public key, but every time I export() a key, I have to input my password.

I also wish I could get the public key directly from the Key class, or that the private_key method on the Identity and Certificate classes worked.

@fcheung
Copy link
Owner

fcheung commented Feb 1, 2015

I'm not that familiar with how the underlying api for certificates / identities works. Any ideas @cifs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants