Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2395233
  • 博文数量: 328
  • 博客积分: 4302
  • 博客等级: 上校
  • 技术积分: 5486
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 11:14
个人简介

悲剧,绝对的悲剧,悲剧中的悲剧。

文章分类

全部博文(328)

文章存档

2017年(6)

2016年(18)

2015年(28)

2014年(73)

2013年(62)

2012年(58)

2011年(55)

2010年(28)

分类: iOS平台

2016-03-03 07:40:54

The hardest thing we ran into for our iOS setup is the iOS security key signing. The security key signing is essential when we automate the deployment and testing of a physical iOS device (rather than testing on the simulator, which doesn't require these extra steps). Codesign tries to ask for the keychain password in a modal dialog. This attempt fails since there is no graphical session. This is why we get the "User interaction is not allowed." error message.

In order to be able to sign Xcode applications it is required to access the certificates for signing. These certificates are stored inside a keychain. The keychain must be open in order to retrieve the certificate for the built application. 


The Solution


The preferred way to open the keychain is during startup of the slave process.
But so far there is no known way to open the keychain when the slave process is launched. The second best way to open the keychain is to unlock it inside the Hudson/Jenkins job. The example code for opening a keychain looks like:

  1.   #!/bin/bash

  2.    ...
  3.   # for debug use
  4.   security list-keychains

  5.    keychain=<PATH_TO_KEYCHAIN_FILE> # e.g. $HOME/Library/Keychains/login.keychain
  6.    security unlock-keychain -p "" ${keychain} &>/dev/null
  7.    
  8.    if [ $? -ne 0 ];then
  9.      echo "Cannot open keychain ${keychain}"
  10.      exit 1
  11.    fi

  12.    ...

Security Advices

In order to secure the password contained as plain text in the shell perform the following steps

  • the umask should be set to 0077. This ensures that all files are created with access right 700. This ensures that config.xml files that contain the password in plain text cannot be accessed by other users.
  • #!/bin/bash -x must not be used. When the -x flag is used the commands are prompted into the log.
  • any output of the security call should be redirected to /dev/null
  • set the HISTSIZE to 0. (e.g. export HISTSIZE=0 inside ~/.bashrc). This prevents the password to be contained in the history.
  • Use Hudson/Jenkins security. Restrict the access rights in a way that the job configuration can only be read by authorized users.
  • Hudson/Jenkins should run under a dedicated user.

Tipps and Tricks

  • By default keychains are locked after a timeout interval. In long running builds it might happen that the keychain is closed again before the code sign step happens. The keychain will remain open infinitly after the command security set-keychain-settings  . It is sufficient to execute this command once in a shell since the timeout is a property of the keychain. It is not required to put this command into the maven build jobs in order to get it executed during each and every build.


阅读(1290) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~