Got it.
This has been some keychain misconfiguration issue.
User A's digital identity was spread over different keychains:
The certificate was located in the system keychain.
The related private key was located in the login keychain.
That's why keychain access did not show any digital identity under 'my certificates'.
codesign however was able to use these scattered items.
Additionally, other unrelated private keys were located in the system keychain.
This led me export a digital ID with an invalid combination of key and
certificate. This digital ID did not work for codesigning with user B.
Exporting the digital ID of User A with a valid combination of private key and
certificate and importing this for User B has solved the problem.
By the way, the following article has been very enlightened:
Certificate Signing Requests Explained: https://developer.apple.com/forums/thread/699268
Thanks!
Topic:
Code Signing
SubTopic:
Certificates, Identifiers & Profiles
Tags: