Importing a private key with /usr/bin/security fails after importing public key

Originator:heath.borders
Number:rdar://27982844 Date Originated:23-Aug-2016 11:31 PM
Status:Open Resolved:
Product:OS X Product Version:10.11.6
Classification:Serious Bug Reproducible:Always
 
Summary:
If I import a public key before importing a private key, /usr/bin/security tells me that the private key import succeeds, but when I run `security find-identity`, it doesn't show my private key in the identities list. However, if I import the private key without the public key existing, then everything works normally.

Steps to Reproduce:

Run the following script:
```
security add-certificate foo.cer
security import foo.pem -k ~/Library/Keychains/login.keychain -T /usr/bin/codesign -T /usr/bin/security
security find-identity
```

Expected Results:
The identity from foo.pem should be printed

Actual Results:
The identity from foo.pem is not printed.

Notes:
Workaround: delete the public key before trying to import a private key

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!