8

我有一个构建包的 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.

4

3 回答 3

3

如果您需要将 Bamboo 作为 运行root,那么您需要使用 Keychain Access(应用程序 > 实用程序)将适当的证书从您的登录钥匙串复制到您的系统钥匙串。

话虽如此,以用户身份运行 Bamboo 而不是root. 例如,如果您需要使用移动配置文件在同一台服务器上签署任何 iOS 构建,root则无法正常工作。

于 2013-11-13T17:11:40.660 回答
1

您是否尝试过 sudo'ing 操作?

IE:

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

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

于 2013-08-26T10:16:49.700 回答
0

我的建议是将您需要的密钥存储在单独的钥匙串中。这将使查找和管理它们变得更加容易。只需创建一个新的钥匙串并将您的证书移入其中;将其存放在方便的地方。然后我以这种方式签名(我正在使用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
于 2013-11-13T17:22:18.227 回答