Greetings,
I'm trying, in a macOS, to perform digital signatures in a list of documents and, currently, facing a problem: for each single document, the method 'SecKeyCreateSignature' is asking for the keychain credentials in order to perform the operation, which goes against the current requirements for the piece of software I'm currently coding.
Ideally, I would like to be able to perform a series of signatures for a given Identity, almost like as if it were a "signature session".
I've used, primarily, the methods 'SecIdentityCopyPrivateKey' and 'SecKeyCreateSignature' in order to perform such task but, now I'm not sure if this is the correct approach anymore, since I've got weird (and different) results when trying this using a p12 certificate imported in the KeyChain and when using a USB Smartcard for the signature:
P12 in the KeyChain: Many credential prompts (relative to the number of items to sign).
USB Smartcard with proprietary driver: Only 1 credential prompt (the number of items to sign does not affect the number of prompts);
So, regarding the above situation, I'd like some help regarding the following points:
Is the pair of functions 'SecIdentityCopyPrivateKey' and 'SecKeyCreateSignature' the most adequate for the current task?
Is there any concept/API for "signature sessions" which I've missed?
Thanks in advance.
What we're looking for is some way to use the signing operations in a fashion that resembles the following pseudo-code
This model isn’t really supported on macOS.
btw The reason you’re seeing this with your smartcard is that a smartcard looks like a new keychain, so the first use of the key prompts the user to unlock that keychain (point A in my 27 Aug post).
The mentioned code snippet is part of a
which is loaded by a app written in Java, hence the allowed executable in the ACL would be.dylibjava
Hmmm. But this is a double-clickable app, right? Most folks who build Java-based double-clickable Mac apps embed the Java runtime within their app. In that case the Java side of this is irrelevant: When you sign your app you can give it a sensible designated requirement (DR) [1], and thus accurately represent the app in a keychain ACL.
One thing you might consider is putting this digital identity in a separate keychain, which would give you something more like the smart card case.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"[1] In modern code signing the DR is formed by a combination of your Team ID and the code signing identifier. For bundled code, like a standalone Mac app, this defaults to the bundle ID. In other cases you can force a specific code signing identifier via the
-i option to
codesign.