{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/ios-code-signing-error/",
  "atlas": "https://www.pystone.net/?node=ios-code-signing-error#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/ios-code-signing-error.md",
  "context": "https://www.pystone.net/notes/ios-code-signing-error.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:ios-code-signing-error",
  "slug": "ios-code-signing-error",
  "title": "iOS Application Code Signing Error",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "iOS Application Code Signing Error",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "6a8b8828b95c75b05edb0ca1080f306025e5ed6e3987fc682ed155618928e3bc",
  "assets": [
    {
      "reference": "assets/1Alhqe4VQgMh1FEE81ZfkBg.png",
      "url": "/media/1f625269c423828d072b.png",
      "mediaType": "image/png",
      "contentHash": "1f625269c423828d072b814f83657b0d35acbdf20834f957c59b4eacf33bdbc2",
      "byteLength": 348432,
      "width": 1400,
      "height": 636
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "iOS Application Code Signing Error",
      "anchor": "ios-application-code-signing-error",
      "citation": "https://www.pystone.net/notes/ios-code-signing-error/#ios-application-code-signing-error"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:software-engineering-and-quality",
      "title": "软件工程与质量保障",
      "url": "https://www.pystone.net/notes/software-engineering-and-quality/",
      "atlas": "https://www.pystone.net/?node=software-engineering-and-quality#knowledge-atlas",
      "label": "软件工程与质量保障",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "CI-CD与质量保障/CI-CD工具链中的“iOS Application Code Signing Error”导航项",
      "citation": "https://www.pystone.net/notes/software-engineering-and-quality/#ci-cd%E4%B8%8E%E8%B4%A8%E9%87%8F%E4%BF%9D%E9%9A%9Cci-cd%E5%B7%A5%E5%85%B7%E9%93%BE"
    }
  ],
  "contentMarkdown": "# iOS Application Code Signing Error\n\n> 创建时间：2022/2/22 22:22\n\nI tried to fix this issue that was a nightmare for me during all the last week and fixed it at the end of the long endeavor. It wasn’t a common solution.\n\nDo you really need to this article for fixing?\nMaybe.\n\nBecause during the investigation, I’ve read too many forums (include Chinese ones. but not read, only look :)), articles, StackOverflow entries etc. but none of them could help me. Therefore I want to create a fixes **compilation** for this issue.\n\nBefore the start, you can find my scenario in the following.\n\nI have a Cordova application and generate a build via Cordova CLI. But generally, this isn’t different than the native ios application build. Actually, It was working correctly until the MacOS and XCode updates.\n\n![](assets/1Alhqe4VQgMh1FEE81ZfkBg.png)\n\nAfter the Mojave and XCode 10 updates, I can’t generate a build on the Jenkins. In the following error was appeared continuously. This is the keychain and certificate dependent issue exactly.\n\n    .......... **errSecInternalComponent**\n     **Command /usr/bin/codesign failed with exit code 1**\n\nWe can start to solutions. You should know those common solutions are at the beginning of the list.\n\n![](assets/0YvG3fIYdbDGpe4Ez)\n\n **Common Solution 1: Check Valid Certificate**\n\nYou should check the keychain to the valid certificate is added correctly. You can do it via the Keychain Access app or the following command via terminal.\n\n    security find-identity -vp codesigning\n\nYour certificate must be in the result. If not, please remove and add your certificate to keychain again.\n\n **Common Solution 2: Lock and Unlock Keychain**\n\nAnother most common solution in here. Run following commands in the terminal. You should add your own keychain name and password.\n\n    security lock-keychain temp.keychain\n    security unlock-keychain -p p@ssw0rd temp.keychain\n\nIn this case, using the keychain name is “temp” and its password is “p@ssw0rd”. Also, you can find keychain’s full path in the following command and it can be used instead of the keychain name (temp).\n\n    security list-keychains\n\n **Common Solution 3: Restart Machine**\n\nIt can be seen as funny but this solution high upvoted on most of the websites. If you add the new certificate, restarting the machine can be useful. You can use the following command to restart.\n\n    sudo reboot\n\n **Common Solution 4: Set Keychain Password to Partition List**\n\nThis solution is fixing password prompt issues. In some cases, codesign waiting for the keychain password from the prompt but remote access doesn’t have this feature. Therefore, generally, the code signing process completed unsuccessfully.\n\n    security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k p@ssw0rd /Users/[redacted-user]/Library/Keychains/temp.keychain-db\n\nYou can find keychain’s full path with the method that was described in “Common Solution 1”.\n\n **My Case’s Solution: Check and Remove Duplicated Private Keys**\n\nIn my case, temp keychain had a valid certificate and its private key. I don’t know why but “System” keychain had a private key that related to my valid certificate. I’ve checked all private keys in all keychains and removed all duplicated keys from irrelevant keychains. Also, I’ve removed all expired certificates if any.\n\nI guess these duplicates was appeared due to Mojave update but really I don’t know why.\n\n **Conclusion :)**\n\n![](assets/0yC5NwjB1GCzan1hy)\n\nMeasure\n\nMeasure\n"
}
