Why is my iOS build failing with "You already have a current Distribution certificate or a pending certificate request"?

Last updated: July 10, 2026

Context

When using automatic code signing with Codemagic, your iOS build may fail during the "Fetch iOS code signing files from Apple Developer Portal" step with the following error:

Did not find any Signing Certificates for given private key
Creating new Signing Certificate: certificate type: DISTRIBUTION
POST https://api.appstoreconnect.apple.com/v1/certificates returned 409:
You already have a current Distribution certificate or a pending certificate request.

This happens when Codemagic cannot find an existing certificate matching your CERTIFICATE_PRIVATE_KEY and attempts to create a new one, but Apple rejects the request because you have already reached the maximum number of Distribution certificates allowed per account. Apple limits this to 3 for a standard Apple Developer Program account and 2 for an Apple Developer Enterprise Program account.

Answer

You have two options to resolve this issue:

  1. Delete an unused Distribution certificate. Log in to your Apple Developer account and remove a certificate you no longer need. This frees up a slot so Codemagic can create a new one. Certificates previously generated by Codemagic are labelled "Created via API".

  2. Reuse the private key from an existing certificate. Update your CERTIFICATE_PRIVATE_KEY environment variable to match the private key of one of your existing Distribution certificates. Codemagic will then find and use that certificate directly instead of creating a new one. Note that this only works if you have access to that certificate's private key — for example, exported as a .p12 from the Keychain of the Mac that created it. Certificates that Codemagic generated via the API can't be reused this way, since their private key isn't recoverable, so for those you'll need option 1.

You can refer to Option 2 in this article for instructions on how to retrieve the CERTIFICATE_PRIVATE_KEY value from an existing certificate.