Nice programing

Sierra의 보안 / 코드 로그인 : 키 체인은 액세스 제어 설정 및 권한에 대한 UI 프롬프트를 무시합니다.

nicepro 2020. 11. 6. 20:05
반응형

Sierra의 보안 / 코드 로그인 : 키 체인은 액세스 제어 설정 및 권한에 대한 UI 프롬프트를 무시합니다.


macOS Sierra부터이 ID를 사용할 때 액세스를 요청하는 usr / bin / codesign UI 프롬프트 없이는 더 이상 / usr / bin / security를 ​​사용하여 코드 서명 ID를 키 체인으로 가져올 수 없습니다. 이것은 빌드 서버의 패키징 스크립트를 손상시킵니다. 해결 방법이없는 것 같습니다. 이는 사용자 정의 생성 키 체인뿐만 아니라 login.keychain에도 영향을 미칩니다.

재현 단계 : 터미널에서 다음 명령을 실행합니다 (가져 오기에 사용할 수있는 서명 ID 필요).

security create-keychain -p test buildagent.keychain
security unlock-keychain -p test buildagent.keychain

security list-keychains -d user -s buildagent.keychain
security default-keychain -s buildagent.keychain

security import identity.p12 -k buildagent.keychain -P password -T /usr/bin/codesign

codesign -vfs '$IDENTITY' '${PRODUCT}' --keychain 'buildagent.keychain'

결과 : macOS는 이전에 가져온 개인 키에 대한 액세스 권한을 요청하는 UI 프롬프트를 표시합니다.

많은 해결 방법을 시도했지만 아무것도 작동하지 않는 것 같습니다.

  • 키 체인 이름을 지정할 때 새로운 .keychain-db 확장명 사용
  • 사용자 정의 대신 login.keychain 사용
  • -A를 사용하여 p12 가져 오기 ( '모든 애플리케이션이 가져온 키에 액세스하도록 허용')
  • 인증서 및 키를 별도로 가져 오기 (이전에 openssl pkcs12를 사용하여 p12에서 추출 됨)

ID 가져 오기는 확실히 작동합니다. Keychain Access 애플리케이션에서 키 체인의 내용을 표시 할 때 인증서와 키를 볼 수 있습니다. 개인 키에 대한 액세스 제어 설정도 올바르게 구성되었습니다 (원하는 코드 서명 예외 규칙 사용).

Sierra에서 UI 프롬프트를 피하려면 어떻게해야합니까?


사용해야하는 명령은 다음과 같습니다.

security set-key-partition-list -S apple-tool:,apple: -s -k keychainPass keychainName

이 명령 줄 도구는 목록 키 체인의 수정 방법처럼 작동합니다. 단일 값으로 set-key-partition-list를 실행하면 인증서의 모든 partitionID를 덮어 씁니다. 전달 된 값의 유효성을 검사하지 않습니다.

이 명령은 특정 키 체인에 대해 서명 (-s) 할 수있는 키에 대해 PartitionID (-S 뒤의 항목을 쉼표로 구분)로 설정합니다. 코드 서명을 허용하는 실제 partitionID는 apple:입니다.

apple-tool:문서화되지 않았기 때문에 무슨 일이 일어나고 있는지 모르겠지만 키를 가져온 후 거기에 security import있었기 때문에 명령을 복사하여 붙여 넣는 사람들이 깨지는 것을 피하기 위해 보관하고 있습니다.

이 변경 사항은 Mac OS Sierra에서 도입되었으며 문서화되지 않았습니다 (또는 적어도 문서를 찾을 수 없습니다). 10 월 16 일 현재 보안 매뉴얼 페이지에이 명령이 나열되지 않습니다.

자세한 내용은이 버그 보고서를 참조하십시오-http: //www.openradar.me/28524119


Travis 또는 기타 CI에서이 문제가 발생하는 codesign경우 응용 프로그램 ID 목록 에 추가해야 합니다.

security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k keychainPass keychainName

추신 : 나는 keychainName.keychain을 사용하고 있습니다 (추가 .keychain)


이 답변 의 명령은 나를 위해 키 체인을 잠금 해제했지만 현재 응용 프로그램이 키를 사용할 수 있는지 묻는 UI 프롬프트가 여전히있었습니다.

나는 다음과 같은 프롬프트를 막았습니다.

키 체인 접근의 키 체인으로 이동하여 모든 키를 두 번 클릭하고 접근 제어 탭에서 '모든 응용 프로그램이이 항목에 접근하도록 허용'을 선택하십시오.

여기에 이미지 설명 입력

새 키 체인 파일을 Jenkins 빌드 서버에 업로드 할 수 있었는데, 여기서 키 체인 및 프로비저닝 프로파일 플러그인에 의해 잠금이 해제되었습니다 . 이제 빌드가 성공적으로 서명됩니다.


어떤 이유로 security set-key-partition-list나를 위해 작동하지 않았습니다.

I solved it by using the -A option when importing the certificate in the keychain:

security import ${P12_FILE} -k ${KEYCHAIN_PATH} -P ${P12_PASSWORD} -A

There is no need to use the security set-key-partition-list afterwards.

This option allows any application to access the imported key without warning. Hence, it prevents the prompt from showing up. Note that it is insecure as the key is not protected but depending on your build context it might help.

On top of that the keychain must be added to the search list:

security list-keychains -s ${KEYCHAIN_PATH}

Then the keychain should be unlocked. Otherwise a prompt asking for the keychain password will be displayed:

security unlock-keychain -p ${KEYCHAIN_PASSWORD} ${KEYCHAIN_PATH}

Eventually the auto-lock timeout should be disabled. This is in case the build is quite long and the keychain re-locks itself:

security set-keychain-settings ${KEYCHAIN_PATH}

After trying many different solutions, what worked for me was simply changing the password of my keychain.

  • Finder > Go > Utilities
  • Open the Keychain Access utility.
  • Not sure if I needed to do this step: In the left sidebar of the Keychain Access utility, click on My Certificates. Look at the Keychain column to confirm which Keychain your apple developer certificate is in. In my case it was in the "login" keychain.
  • Change the password for the keychain from the previous step. You might want to trying locking it then unlocking it, if it's locked. You change the password by clicking on the relevant keychain ("login", in my case) and then selecting "Change Password..." from the Edit menu of the Keychain Access utility.
  • The next time I ran the archive step in Xcode (in the Product menu) I was eventually prompted for a keychain password and I entered the password for my "login" keychain. Then it worked. When it finished I saw an Archives screen with my app listed in it.

또한 앱이 5 분 이상 빌드 된 경우 사용자 지정 키 체인 잠금 타이머가 부족하고 -1 = ffffffff 오류가 발생할 수 있습니다. 따라서 tmp 솔루션으로 키 체인 잠금을 비활성화하십시오.

참고 URL : https://stackoverflow.com/questions/39868578/security-codesign-in-sierra-keychain-ignores-access-control-settings-and-ui-p

반응형