Skip to content

Commit

Permalink
Do not fail keychain add-certificate on duplicate certs (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
priitlatt authored Nov 6, 2020
1 parent c681eac commit 18b24d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.3.2
-------------

**Improvements**

- Bugfix: Do not fail `keychain add-certificate` action in case the added certificate already exists in keychain.

Version 0.3.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion src/codemagic/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "codemagic-cli-tools"
__description__ = "CLI tools used in Codemagic builds"
__version__ = "0.3.1"
__version__ = "0.3.2"
__url__ = 'https://github.com/codemagic-ci-cd/cli-tools'
__licence__ = 'GNU General Public License v3.0'
6 changes: 5 additions & 1 deletion src/codemagic/tools/keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,12 @@ def _add_certificate(self,
'-T', shutil.which('codesign'),
'-P', certificate_password.value,
], obfuscate_patterns=obfuscate_patterns)

if process.returncode != 0:
raise KeychainError(f'Unable to add certificate {certificate_path} to keychain {self.path}', process)
if 'The specified item already exists in the keychain' in process.stderr:
pass # It is fine that the certificate is already in keychain
else:
raise KeychainError(f'Unable to add certificate {certificate_path} to keychain {self.path}', process)

def _find_certificates(self):
process = self.execute(('security', 'find-certificate', '-a', '-p', self.path), show_output=False)
Expand Down

0 comments on commit 18b24d8

Please sign in to comment.