Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to unlock the keychain

Building a new Jenkins for an iOS app CI story. I created a keychain named build in KeyChainAccess to hold the dev certificate.

I set a password for the keychain. On Jenkins, Manage Jenkins --> Keychains and Provisioning Profiles Management -> choose the build.keychain file and upload.

I filled in the password (the same as what I set earlier). I filled in the certificate (by copy the common name of the certificate info in KeyChain access).

I created a Jenkins job using the Keychain and Code Signing Identity, filled in the password. But when I build the project by Jenkins, it throw the following error in Console Output:

[ProjectName] $ /usr/bin/security unlock-keychain -p ********    /Users/Shared/Jenkins/Home/jobs/JobName/workspace/build.keychain
security: SecKeychainUnlock /Users/Shared/Jenkins/Home/jobs/JobName/workspace/build.keychain: The user name or passphrase you entered is not correct.

FATAL: Unable to unlock the keychain.

I checked the password, I can unlock the build keychain in KeyChain Access using the password. I am not sure what username it asks for, Jenkins?

like image 230
Donald Wang Avatar asked Oct 19 '22 15:10

Donald Wang


1 Answers

It's been a long time since you asked this question but I think it's worth it to answer it!

The output error The username or passphrase you entered is not correct. can be caused by several things but one of the common errors is a wrong keychain path.

To solve it the first thing you need to be sure is that your keychain was created and get its correct path. Run the following command in your console:

security list-keychains

The output should return all the keychains you have, something like this:

    "/Users/jenkins/Library/Keychains/login.keychain-db"
    "/Library/Keychains/System.keychain"

If your build keychain is not there something were wrong during its creation and you need to create it again. In case you keychain is the above list you need to copy the path where the keychain is located.

If for some reason the name of your keychain is duplicated in that list be sure to remove the duplicated keychains running the following command:

security list-keychains -s pathOfTheKeychainDuplicated

Then with the path and the password of the user with access to this keychain you can unlock it using the following command:

security unlock-keychain -p ****** /Users/jenkins/Library/Keychains/login.keychain-db

In the above command, the path should be the one of your build keychain

I hope this helps you.

like image 197
Victor Sigler Avatar answered Oct 21 '22 13:10

Victor Sigler