I'm facing weird situation. For Apple Push Notification I can't export .p12 file from Keychain access. I can highlight both items and click on Export 2 items but after that nothing happens. All steps are correct as I've been doing it all the time. It seems something is wrong with keychain access or my Mac? I did it successfully few days back for another key and it worked, exporting for this old one doesn't work now. I don't think there is any error or problem in generating certificate otherwise it should work for older keys.
Login is selected in left pane. Any suggestions?
This problem also happens when you happen to have selected the wrong keychain (like if you accidentally had single clicked on the System keychain rather than Login keychain). If the cert signing request came from that machine, it would associate the private key with the Login keychain. So if you somehow then downloaded and imported the certificate into the System keychain, Keychain Access would not find the matching private key and would not put the cert under "My certificates", and cannot export a p12. You might as well have tried importing to the keychain on a different Mac.
So, make sure the import is into the keychain associated with the private key. Often this would be the Login keychain.
Rebooting machine worked in my case.
I'm attempting to sign an iOS Enterprise application via 3rd party app creation tool, FlipLet.
From my keychain, I export the distribution certificate to obtain a p12 for signing. When it prompts for password I hit OK to leave it blank then enter admin password to allow the export. After it's done, I open the p12 file and it prompts for password, which I wouldn't expect because there was none set. I can just hit enter to bypass as if it recognizes there isn't one.
Any idea how to get it to not prompt as the signing tool is gettin hung on it. I've tried the app iReSign and it fails as well, I assume from the same issue.
To change whether a root certificate is trusted, open it in Keychain Access and modify its Trust Settings. New root certificates should be added to the login keychain for the current user, or to the System keychain if they are to be shared by all users of this machine.
I have tried removing all certificates and adding them again, but I am still getting this error. I also tried dragging and dropping the certificate on the "Certificates" section, and it added successfully, but it was not displayed in Xcode
I also tried This link
When signing an app from an ssh terminal session, I am getting the following error:
productsign[29321:707] SignData failed: CSSMERR_CSP_NO_USER_INTERACTION (-2147415840)
productsign was working until recently.
How do I get around this error?
I solved it by accident - after combing the web for hours - while reproducing the steps when filing an incident report with Apple Support.
From the Mac (as opposed to from an ssh session) the same command generated a popup asking for permission to access the Keychain.
After choosing "Always Allow" the problem went away. Forever.
try to unlock keychain from this terminal:
security -v unlock-keychain -p "<Password>" "/Users/<UserName>/Library/Keychains/login.keychain"
Based on Danny Schoemann's answer and my own research I found complete solution for me:
You really need login to your mac machine using GUI, first time, and sign anything with the certificate that you need. Then you will get request window with available option "Always allow" to use this certificate (or smth like that).
Important: if you need to use productsign with ssh or other console session (like Jenkins), your certificate must by installed into system scope, but not into user scope.
If you need to keep your certificate in user scope, you need to unlock your keychain every time in console session when you need to sign something (as Alex wrote):
security -v unlock-keychain -p "Password" /Users/<UserName>/Library/Keychains/login.keychain"
You may put it into you build script.
Obvious minus of this solution - you need to store your password in some unencrypted script, that is insecure, so I prefer first solution.
You can actually fix this error. When you are in productsign you are using the Developer ID Installer certificate and generally suggests that it doesn't have access to Private key for signing where it fails with this error.
To fix this goto
Keychain Access->Click on the Little Triangle Arrow (>) in front of "Developer ID Installer" certificate under login keychain or your appropriate keychain.
Double click on the Private Key
Click on "Access Control" tab
Select "Allow all applications to access this item"
Now try productsign from commandline again, it should work.
I've looked through already existing questions, but none has solved my problems (like recreating certificates). I've built an app where inside the app I have few executables and folders and frameworks. Whenever I try to do codesign -s "our identity" my.app always gives no identity found. Can someone give a step by step process of this.
codesign -s "Developer ID Application: Sai***** (123123123J)" out/Release/Sai.app
Error
Developer ID Application: Sai****** (123123123J): no identity found,
I tried removing "Developer ID Application" and the serial number, but everything gives the same error
Looking for help in these lines
I had some trouble with this as well. Double-check that your code-signing identity is in your keychain, and you might consider using the SHA-1 fingerprint instead of the name after the -s.
You can find the SHA-1 fingerprint by opening up Keychain Access and selecting your Developer ID Application: FOO certificate, and then choosing Get Info. From here, scroll to the bottom of the information until you reach Fingerprints. The SHA-1 fingerprint here can be copied and you will have to remove all of the spaces, but after that you will have a 40-character identifier which will be appropriate for placing after the -s in your codesign statement.
If you are still having problems locating the key, try the following from Terminal:
certtool y | grep Developer\ ID
and look for anything with Developer ID Application in the Common Name to verify that the certificate is actually in a keychain that is accessible from Terminal. If you don't see anything in response, that would indicate that the keychain containing your credentials is unavailable to your Terminal session. Reasons for this would include things like the keychain being locked, the shell running as another user, executing the command with different permissions (such as sudo).
After executing the command above, you should have at a minimum the following:
Developer ID Application: <your company name>
Developer ID Installer: <your company name>
Developer ID Certification Authority
If you don't have all three, you should go and download the missing elements. Although you may not currently need to build an Installer, there's no harm in having it around. The Application and Installer elements can be downloaded from the Mac Certificates section of the Certificates, Identifiers, & Profiles tab on Apple's Developer site. You should have listings there that are not expired. You may have listings there as well that have expired. To install the certificates in your keychain:
Access the Apple Developer Site
Access the Mac Dev Center
Access Certificates, Identifiers, & Profiles link
Download the Certificates from the portal
Double-click on the Certificates and Keychain Access should open
Allow Keychain Access to add the Certificates to your Keychain
The Developer ID Certification Authority should have been installed by Xcode, but if it wasn't, you can install it yourself. You will need to download that separately from Developer ID Authority or by clicking on the + link in Certificates tab and use the link at the bottom to download the Certificate.
This would also be a good time to make sure that you have the Apple Worldwide Developer Relations Certification Authority, which is the basis for some of the signing tools. It should be installed in your System keychain, by the Xcode installer and can be downloaded directly from the + link in the Certificates tab above or from Apple WWDR CA.
According to Apple's App Distribution Guide, there are specific keychains that are appropriate for each of the Certificates and keys:
Your private Keys and your signing certificates (Developer ID Installer,Developer ID Application, and the App Store Certificates) should be in your login keychain
The Apple Worldwide Developer Relations Certification Authority and Developer ID Certification Authority belong in the System keychain
Your developer certificates also belong in your login keychain
Keychain Maintenance
Because Xcode automatically manipulates the keychains, and because some certificates are re-issued regularly when profiles change (although not for Developer ID, since it has multi-year certificates and doesn't require profiles), you can end up with a propagation of unnecessary and potentially confusing certificates in your keychain. It is a good idea to clean these out when they have expired, as they can create some confusion for Xcode.
WARNINGS
Before performing any maintenance on your Keychains, make sure you have a backup of your keychains
This process is intended for removing unnecessary Certificates relating to development, If the certificates don't start with Mac Developer, 3rd Party Mac Developer, iPhone Developer or Developer ID, do not mess with them at this time. If you accidentally delete the Certificate you received with an email (for example), even if it has expired, you may not be able to read the email that you received.
Things to do:
Quit Xcode
Run Keychain First Aid (from Keychain Access) and verify that your keychains are OK
Click on the Certificates Category on the left sidebar
Locate any expired developer certificates of the kinds mentioned above. They will show up with a small X in the lower right corner.
Select the Certificates you will be removing and back them up by using File > Export Items...
Put this file in a safe place and give it a good password
Delete the Certificates which you have backed up
Look through your remaining certificates and verify that you have the certificates mentioned in the preceding section. If you don't, you'll need to download, and possibly renew them.
Verify that the certificates are in the keychains that are indicated above (all your signing certs should be in your login keychain, for example)
while I did not do this for apple development code signing, I still think I have some valuable inside that could help you debug such a problem. The difference is that I created my own certificate while you got one from apple.
Check the trust of the cert, it must be trusted for code signing (on yosemite that is the third last in the trust section of the cert view in the keychain access). Be aware that for your code signing the cert should be in the login keychain, I needed it in the System keychain.
At first the cert was not known for codesigning to the keychain, because there was the Extension purpose "Code Signing" missing, you can find this if you look into the keychain and double click on the certificate:
I fixed that (you can not fix it as Apple provides the cert to you. The extension should just be there):
Then I added the certificate to the trusted signing certificates, after I had drag&dropped the certificate from the keychain to my desktop, which created the ~/Desktop/gdb-cert.cer (be aware you can omit -d and -r trustRoot:
$ sudo security add-trusted-cert -d -r trustRoot -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/gdb-cert.cer
This was a bit tricky because I was mislead by some internet posts and did not look at the man page. Some said you should use add-trust (https://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt). The terrible bit was that the command succeeded, but did not do what it should.
After that I found the new cert in the trusted certs like so:
$ security find-identity -p codesigning
Policy: Code Signing
Matching identities
1) E7419032D4..... "Mac Developer: FirstName LastName (K2Q869SWUE)" (CSSMERR_TP_CERT_EXPIRED)
2) ACD43B6... "gdb-cert"
2 identities found
Valid identities only
1) ACD43... "gdb-cert"
1 valid identities found
In my case the apple cert is expired, but the one I was using to sign gdb was not (well, I just created it myself). Also be aware that the policy is named differently for the "security add-trusted-cert"(-p codeSign) and the "security find-identity" command (-p codesigning). I then went on to sign gdb and I also always got:
$ codesign --sign gdb-cert.cer --keychain ~/Library/Keychains/login.keychain `which gdb`
gdb-cert.cer: no identity found
because I was under the impression that I had to give the file name of the cert file to the --sign option, but that in fact was the CN of the certificate that I should have provided and should be in the trust store. You can find the CN here when double clicking on the cert in the keychain:
or in the above output of "security find-identity -p codesigning". Then I went on to sign and I had to give it the right keychain. In your case this would have to be the ~/Library/Keychains/login.keychain, in my case the System.keychain:
codesign -s gdb-cert --keychain /Library/Keychains/System.keychain `which gdb`
That then gave me a working gdb and it should give you a signed application.
The Answer finally was very simple. My Private Key was missing.
For this I revoked the certificate and followed its steps in developer program (Especially creating CSR certificate during the process, which I did not get several times, unless I revoked the certificate).
As even
certtool y | grep "Developer ID Application: xxxx"
could not display any results, I guessed it was an issue of accessing the desired keychain. So first I verified, the private key could be accessed by any applications in the keychain itself and then I started to use the k=/Users/myUser/Library/Keychains/login.keychain option in the certtool command and as this succeeded I did the same with
codesign --keychain /Users/myUser/Library/Keychains/login.keychain --force --verbose -s "Developer ID Application: xxxx"
As even
certtool y | grep "Developer ID Application: xxxx"
could not display any results, I guessed it was an issue of accessing the desired keychain. So first I verified, the private key could be accessed by any applications in the keychain itself and then I started to use the k=/Users/myUser/Library/Keychains/login.keychain option in the certtool command and as this succeeded I did the same with
codesign --keychain /Users/myUser/Library/Keychains/login.keychain --force --verbose -s "Developer ID Application: xxxx