Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding certificates with empty password to keychain on macOS 15.1 #436

Merged
merged 3 commits into from
Nov 6, 2024

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Nov 6, 2024

This is a continuation of #428

On macOS 15.1 security import -f pkcs12 fails when trying to import PKCS#12 containers that have been exported from Keychain Access using empty passphrase:

% security import certificate.p12 -f pkcs12 -k kc.keychain-db -P '' -T /usr/bin/codesign -T /usr/bin/productsign                                            
security: SecKeychainItemImport: The user name or passphrase you entered is not correct.

Importing the same container with OpenSSL format specifier using -f openssl option is successful.

Updated actions:

  • keychain add-certificates

@priitlatt
Copy link
Contributor Author

QA notes

I tested it using two PKCS#12 containers containing the same certificate. Both were exported from Keychain Access with empty password - one on macOS 14.7 and the other on macOS 15.1. The following workflow was used for testing in Codemagic:

codemagic.yaml
workflows:
  add-certificates:
    inputs:
      certificate_name:
        description: Certificate name
        type: choice
        options:
          - certificate-macos-14-7-export.p12
          - certificate-macos-15-1-export.p12
      xcode:
        description: Xcode version
        type: choice
        default: latest
        options: [latest, 16.2, 16.1, 16.0, 15.4, 15.3, 15.2, 15.1, 15.0]
    environment:
      xcode: "${{ inputs.xcode }}"
    scripts:
      - python -m pip install --upgrade https://github.com/codemagic-ci-cd/cli-tools/archive/refs/heads/bugfix/keychain-add-certificates-on-macos-15-1.zip
      - keychain --version
      - keychain initialize
      - keychain add-certificates --certificate ${{ inputs.certificate_name }} --verbose
      - keychain list-certificates | jq

Both certificates were successfully added to keychain regardless of Xcode and macOS (14.7, 15.0 and 15.1) versions.

@priitlatt priitlatt marked this pull request as ready for review November 6, 2024 14:09
@priitlatt priitlatt requested a review from fran-tirapu November 6, 2024 14:11
…gfix/keychain-add-certificates-on-macos-15-1
Copy link
Contributor

@fran-tirapu fran-tirapu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@priitlatt priitlatt merged commit c444401 into master Nov 6, 2024
11 checks passed
@priitlatt priitlatt deleted the bugfix/keychain-add-certificates-on-macos-15-1 branch November 6, 2024 15:05
@priitlatt priitlatt added the bug Something isn't working label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants