Certificate Authority for Code Signing in Mac/Apple
Sometime or the other, developers using Mac have come across error messages like no identity found in the keychain or 0 valid identities found while trying to do code signing of some app.
The issue arose because of the mandatory requirement in macOS Monterey that all apps be code signed. We create a Certificate Authority first and a code signing Certificate thereafter, issued by the created certificate authority.
Press Command (⌘)
+ Space Bar
and bring up the Spotlight search window.
Type "Keychain"
and select Keychain Access
.
Click on Keychain Access
> Certificate Assistant
> Create a Certificate Authority...
Fill the name
field with whatever name you decide for your certificate authority. In the Identity Type
and User Certificate
fields, select Self-Signed Root CA
and SSL Server
from the options respectively.
Click on Create
, and the certificate authority is created.
But the certificate authority you just created is marked red, with the message reading: "this root certificate is not trusted".
To resolve this, double click on the newly created certificate. A window pops up, and you will see the collapsed Trust
panel. Expand the panel.
You will find the When using this certificate:
field. From the options, select the Always Trust
option and save the changes.
Now the certificate is trusted for your account. The red warning message is no more.
Now that a certificate authority has been created, we next create a code signing certificate.
Click on Keychain Access
> Certificate Assistant
> Create a Certificate...
A form pops up. The name
field you can fill with whatever name you fancy. In the Identity Type
and User Certificate
fields, select Leaf
and Code Signing
from the options respectively. Also, check the Let me override defaults
box just below.
In the next page of the form, fill the Email
field. Then click on Continue
.
Next, you get the Choose An Issuer
form where your newly created Certificate Authority comes auto selected. Click Continue
.
The next consequent steps are outlined in the image below.
After clicking on the Create
button of the last step, the code signing certificate is created.
Your certificate is listed in the Keychain Access
.
Now bring up the terminal and type the following command:
security find-identity -v
Now bring up the terminal and type the following command:
security find-identity -v
Your will find something akin to the lines below.
To bring up just the code signing certificate(s), refine the command as below:
security find-identity -v -p codesigning
They will be listed as:
If however you find output messages like
0 valid identities found
which obviously would have given way to messages like no identity found in the keychain error when codesigning an app, you need to download the Apple WWDR CA from here.
find / -libphp7.so
code sign libphp7.so
codesign -f -s 59A385A3526927AD6089FB2F57A5605B22AD5C57 /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so