Renewing an Expired Apple Distribution Certificate (iOS)
I’ve just received the dreaded E-Mail saying my Distribution Certificate would no longer be valid in 30 days. That certificate is used to sign the Camjam photo sharing app - or at least I think that’s what it’s used for.
Camjam is built using an Azure DevOps build pipeline so I’ll ultimately have to replace some Secure Files there.
These are the steps that I’ve finally come up with:
1) Generate the Certificate
Here, you’ll end up with a *.p12
certificate file which will later be uploaded to Azure Pipelines.
You need to do this on a Mac.
- Follow the steps on https://help.apple.com/developer-account/#/devbfa00fef7 to Create a certificate signing request which are:
- Launch Keychain Access located in /Applications/Utilities.
- Choose Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority.
- In the Certificate Assistant dialog, enter an email address in the User Email Address field.
(I entered the main email of the company publishing Camjam.) - In the Common Name field, enter a name for the key (for example, Gita Kumar Dev Key).
- Leave the CA Email Address field empty.
- Choose Saved to disk, and click Continue.
- Go to Certificates in the Apple Developer portal at https://developer.apple.com/account/resources/certificates/list
- Klick the little blue icon with the + symbol next to Certificates.
- Choose Apple Distribution and click Continue.
- Coose the file you created in step 1.6.
- On the Download Your Certificate page, click Download and save the file.
- In Finder, double-click the file you just downloaded.
(This will add the certificate to your key chain and display it there.) - Right click the new certificate in the key chain program and export.
(This generates a*.p12
file which you’ll need in Azure Pipelines.) - You will be prompted to enter a password. Use the password from when you exported the previous certificate (i.e. a year ago). If you don’t know that password any more, make up a new one.
If you’ve entered a new password, you’ll need it later in Azure Pipelines.
2) Update the existing Provisioning Profile
Here, you’ll end up with a file containing your updated Provisioning Profile which will later be uploaded to Azure Pipelines.
- Go to Profiles in the Apple Developer portal at https://developer.apple.com/account/resources/profiles/list and click on your existing profile.
Remember: This post is about an App that’s already in the App Store, so there must be an existing profile. - Click Edit
- Under Certificates select the entry with the later expiration date (i.e. the certificate just added).
- Click Save
- Download the Provisioning Profile you’ve just edited.
3) Replace the Secure Files in Azure Pipelines
In the Library of your Azure Pipelines project, you should already have two Secure Files. One for the Certificate (*.p12
) and one for the Publishing Profile.
- In Azure Pipelines, navigate to Library > Secure Files
- In the list of Secure Files, there should be one for the Certificate and one for the Provisioning Profile already. Change the names of both of them (e.g. add a suffix “_expired” to both).
- Upload the Certificate (
*.p12
) and after uploading, change its name to the respective original Secure File entry. - Upload the Provisioning Profile (
*.mobileprovision
) and after uploading, change its name to the respective original Secure File entry. - Optional: If you’ve entered a new password while you generated the
*.p12
file, you also have to update the variable that holds it. You can find out that variable’s name by checking out your buildyaml
. It’s the value ofcertPwd
of theInstallAppleCertificate@2
task.
4) Clean up
- Try if your build that’s using the two Secure Files succeeds.
- If the build succeeds, you might want to delete the two old Secure Files (the ones you’ve renamed above).
- If you’ve made up a new password for the
*.p12
file, it’s a good idea to note it somewhere.
Hire me! Web frontend with JavaScript, TypeScript, React, Svelte, HTML, CSS. Backend with .Net/C#, Node.js, (MS-)SQL. I fill your resource gaps, take on whole projects and create prototypes. Yes, tell me more