Skip to content

Instantly share code, notes, and snippets.

@yonat
Created July 11, 2023 08:25
Show Gist options
  • Select an option

  • Save yonat/56495c07d3c76a320d9be0721682daf3 to your computer and use it in GitHub Desktop.

Select an option

Save yonat/56495c07d3c76a320d9be0721682daf3 to your computer and use it in GitHub Desktop.

Revisions

  1. yonat created this gist Jul 11, 2023.
    21 changes: 21 additions & 0 deletions generate_push_certificate.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Generate push certificates.
    # Usage: generate_push_certificate <app-bundle-id> <user-email> <cert-password>
    generate_push_certificate() {
    app=$1
    user=$2
    password=$3

    fastlane pem -a "$app" -u "$user" -p "$password"
    convert_push_certificate_to_keychain_format "production_${app}_ios.p12" "$password"
    }

    # Convert p12 to Keychain acceptable format.
    # Usage: convert_push_certificate_to_keychain_format <cert-file.p12> <cert-password>
    convert_push_certificate_to_keychain_format() {
    cert=$1
    password=$2

    /opt/homebrew/opt/openssl@1.1/bin/openssl pkcs12 -in "$cert" -out temp.pem -passin pass:"$password" -passout pass:"$password"
    /opt/homebrew/opt/openssl@1.1/bin/openssl pkcs12 -export -in temp.pem -out "keychain_$cert" -passin pass:"$password" -passout pass:"$password"
    rm temp.pem
    }