import_certificates_match.mo
Owner: Louis Lagrange
When using Fastlane's Match, you might want to update the certificates or provisioning profiles manually if you don't have enough rights on the publisher's Apple developer account (meaning that you're unable to create certificates and provisioning profile by your own or by using match).
Prerequisites (~10 min)
A
.p12distribution certificate and its password, saycert.p12A
.mobileprovisionprovisioning profile, sayprofile.mobileprovisionAn Apple developer account that has read access to the publisher's Apple developer account (check by logging in)
Write access to the Match git repo, say
certificates.gitThe app's bundle identifier:
BUNDLE_IDENTIFIERA
list_certificateslane in yourFastfile:
import fastlane_require 'spaceship'
# ...
platform :ios do
lane :list_certificates do
Spaceship.login
Spaceship.select_team
Spaceship.certificate.all.each do |cert|
cert_type = Spaceship::Portal::Certificate::CERTIFICATE_TYPE_IDS[cert.type_display_id].to_s.split("::")[-1]
puts "Cert id: #{cert.id}, name: #{cert.name}, expires: #{cert.expires.strftime("%Y-%m-%d")}, type: #{cert_type}"
end
end
# ...Steps (~20 min)
Install the distribution certificate in your
Keychain(double click)In your
Keychain, under "My certificates", export the certificate in the.cerformat (right click), saycert.cerFind the new distribution certificate's ID
Run
bundle exec fastlane ios list_certificateswith the account that has access to the publisher's Apple developer accountFind the line corresponding to the new distribution certificate and note the certificate ID
CERT_ID
Extract the private key from
cert.p12:openssl pkcs12 -nocerts -nodes -out cert.pem -in cert.p12Open
cert.pemin a text editor and make sure it starts with-----BEGIN RSA PRIVATE KEY-----. If it's the case, go directly to 7.Convert the private key to a RSA private key:
openssl rsa -in cert.pem -out cert.pemFind the password of the Match git repo's branch (
MATCH_PASSWORD) in your secret filesCypher the private key with the Match algorithm:
openssl aes-256-cbc -k ${MATCH_PASSWORD} -in cert.pem -out ${CERT_ID}.p12 -aCypher the public key:
openssl aes-256-cbc -k ${MATCH_PASSWORD} -in cert.cer -out ${CERT_ID}.cer -aCypher the provisioning profile:
openssl aes-256-cbc -k ${MATCH_PASSWORD} -in profile.mobileprovision -out AppStore_${BUNDLE_IDENTIFIER}.mobileprovision -aClone the Match git repository.
Checkout the
MATCH_GIT_BRANCH.Remove the old certificates and provisioning profiles and add the new ones.
Last updated