【问题标题】:Mac OS X - Making Keychain Certificates available to Atlassian BambooMac OS X - 使钥匙串证书可用于 Atlassian Bamboo
【发布时间】:2013-08-15 14:30:16
【问题描述】:

我有一个构建包的 Bamboo 计划,我想用我的开发人员证书签署该包。在我的构建脚本中,我有这个:

productsign --sign "Name of my certificate" "input.pkg" "output.pkg"

从命令行运行此脚本按预期工作。但是,从 Bamboo 运行脚本,我总是得到错误:

productsign: error: Could not find appropriate signing identity for "Name of my certificate"

我认为这一定是因为从 Bamboo 运行构建脚本时运行的上下文。如何使证书在 Bamboo 中可用?它安装在System,而不是login

【问题讨论】:

    标签: macos installation code-signing bamboo


    【解决方案1】:

    如果您需要以root 的身份运行 Bamboo,那么您需要使用 Keychain Access(应用程序 > 实用程序)。

    话虽如此,以用户身份运行 Bamboo 而不是 root 可能会更好。例如。如果您需要使用移动配置文件在同一服务器上签署任何 iOS 版本,root 将不起作用。

    【讨论】:

    • 如果您从 LaunchDaemon 运行 Bamboo 代理,您可以通过将 UserName 字段添加到 LaunchDaemon plist (UserNameyourusername) 来指定要运行的 Bamboo >)
    • 我将 Bamboo 代理配置为作为 LaunchDaemon 启动,并且我还指定了用户名,但 xcodebuild 仍然无法访问钥匙串中的密钥。我不得不将钥匙从login 钥匙串移动到System,这对我有用。
    【解决方案2】:

    您是否尝试过 sudo 操作?

    即:

    sudo productsign --sign "Name of my certificate" "input.pkg" "output.pkg"
    

    由于密钥在系统钥匙串中(也许它不应该用于您的用例?),您可能无法以“普通”用户的身份访问它,即使 [按设计] 您拥有访问其中的证书。

    【讨论】:

    • 我已经尝试过了,但不幸的是,你得到了同样的错误
    • 那太容易了,对吧?导出密钥并将其导入回登录钥匙串怎么样?如果您用来识别密钥的 CN 是正确的,那么几乎没有其他东西会妨碍签名处理。
    【解决方案3】:

    我的建议是将您需要的密钥存储在单独的钥匙串中。这将使查找和管理它们变得更加容易。只需创建一个新的钥匙串并将您的证书移入其中;将其存放在方便的地方。然后我以这种方式签名(我使用的是codesign,但--productsign 是一样的)。我不以 root 身份构建,也不为此使用 sudo。

    # Keychain that holds all the required signing certificates
    # To create a keychain like this, create it in "Keychain Access" and copy all your certificates into it
    # Then set its timeout to infinite (so it doesn't re-lock itself during the build):
    #    security set-keychain-settings <path>
    # Passing no "-t" option means "no timeout."
    # Generally you should just be able to copy this file from build host to build host as needed. Then
    # add it to the available keychains using Keychain Access, File>Add Keychain…. If you don't add it to
    # Keychain Access, you'll receive signing error CSSMERR_TP_NOT_TRUSTED, since it won't recognize the
    # entire chain
    keychain=~/Library/Keychains/MyProduct.keychain
    keychain_password=somepassword # If you have one on the keychain
    cert_identifier='My Signing Name'
    ...
    
    # We assume the keychain has an infinite timeout, so we just unlock it once here.
    if ! security unlock-keychain -p "${keychain_password}" ${keychain} ; then
      echo "Cannot unlock keychain. Cannot sign on this host."
      exit 1
    fi
    
    sign()
    {
      name=$1 ; shift
      paths=$*
    
      if ${sign} ; then
        echo "** SIGNING $name **"
        chmod u+w $paths
        codesign --keychain ${keychain} -f -s ${cert_identifier} $paths
      fi
    }
    
    sign "The Whole Package" something.pkg
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多