NeuroAgent

Fix iOS EAS Build: Certificate Import Error

Fix iOS EAS build failures with distribution certificate import errors. Learn troubleshooting steps, certificate validation, and proper .p12 creation methods for successful iOS builds.

Question

iOS EAS Build Fails – “Distribution certificate hasn’t been imported successfully”

I’m developing a React Native app using Expo SDK 54. The Android build works perfectly, and the app runs fine on iPhone devices via expo start --tunnel. However, I’m encountering an issue when building for iOS through EAS for TestFlight testing.

I don’t have an Apple Developer account—a collaborator who owns one has provided me with:

  • .p8 key file (App Store Connect API key)
  • Key ID and Issuer/Developer ID
  • Bundle ID
  • .mobileprovision profile
  • .p12 distribution certificate (created on Windows using OpenSSL)

All credentials were uploaded via credentials.json, and the build starts but fails with:
“Distribution certificate with fingerprint [XXXX] hasn’t been imported successfully”

Could this be due to:

  1. A mismatch between the provisioning profile and certificate?
  2. The .p12 being generated on Windows instead of macOS using KeyChain?

What troubleshooting steps should I try next? Should we recreate the .p12 file on a macOS device?

NeuroAgent

iOS EAS build failures with distribution certificate import issues typically stem from certificate provisioning profile mismatches, incorrect certificate format, or corrupted certificate files. The error “Distribution certificate hasn’t been imported successfully” almost always indicates that the certificate fingerprint in your EAS configuration doesn’t match what’s actually in your uploaded certificate file, or there’s a fundamental issue with how the certificate was created or exported.

Contents

Understanding the Certificate Import Error

The error message “Distribution certificate with fingerprint [XXXX] hasn’t been imported successfully” is a specific EAS build error that indicates a mismatch between what EAS expects and what it receives during the certificate validation process. This error typically occurs during the build initialization phase when EAS attempts to verify your iOS distribution credentials.

When you submit a build, EAS performs several validation checks:

  1. Verifies the certificate format and integrity
  2. Checks if the certificate matches the provisioning profile
  3. Validates the certificate fingerprint against what’s stored in your EAS configuration
  4. Ensures the certificate hasn’t been revoked by Apple

The fingerprint mentioned in the error is the SHA-1 hash of your certificate’s public key. If this fingerprint doesn’t match what EAS expects, or if the certificate itself is malformed, you’ll receive this error.

Common Causes of Certificate Import Failures

Certificate-Provisioning Profile Mismatch

The most common cause of this error is indeed a mismatch between your distribution certificate and provisioning profile. When your collaborator created these credentials, they must have:

  • Generated the distribution certificate on their Mac using Keychain Access
  • Created a provisioning profile specifically for that certificate
  • Ensured both use the same App ID and bundle identifier
  • Made sure the certificate hasn’t been revoked or expired

If these credentials were created at different times or by different methods, they might not be compatible.

Windows-Generated .p12 Certificate Issues

Creating a .p12 certificate on Windows using OpenSSL is highly problematic for iOS development. Here’s why:

  • Keychain Integration: iOS certificates are designed to be created and managed through macOS Keychain Access, which maintains proper certificate chains and attributes
  • Export Limitations: OpenSSL exports certificates without the complete certificate chain, which Apple requires
  • Format Differences: Windows-generated certificates often lack the proper extensions and attributes needed for iOS distribution
  • Password Protection: The password handling might differ between platforms, leading to corruption

Corrupted or Improperly Formatted Certificate Files

Even if created on macOS, certificate files can become corrupted during:

  • Transfer between devices
  • Email attachments
  • Compression/decompression
  • Text encoding issues

Troubleshooting Steps for iOS Certificate Issues

Step 1: Verify Certificate Fingerprints

First, let’s verify what EAS expects vs. what you have:

bash
# Check your EAS configuration
eas build:configure

# List your credentials
eas credentials:list

Compare the fingerprint mentioned in the error with the actual certificate fingerprint:

bash
# On macOS (if you have access)
openssl x509 -in your_certificate.p12 -noout -fingerprint -sha1

# On Windows (if you must use Windows)
openssl pkcs12 -in your_certificate.p12 -nodes -passin pass:your_password | openssl x509 -noout -fingerprint -sha1

Step 2: Validate Certificate-Provisioning Profile Pairing

Check if your provisioning profile matches your certificate:

  1. Install the .mobileprovision file on a Mac with Xcode
  2. Open it in Xcode → Organizer → Devices
  3. Verify it’s linked to the correct distribution certificate
  4. Check that the App ID/bundle identifier matches your app

Step 3: Test with Xcode Direct Build

Before trying EAS again, test your credentials with a direct Xcode build:

  1. Install the .p12 and .mobileprovision on a Mac
  2. Create a simple iOS project in Xcode
  3. Configure the project with your bundle identifier
  4. Attempt to archive and export

If this fails, your credentials have fundamental issues regardless of EAS.

Step 4: Clean and Re-upload Credentials

Sometimes EAS gets confused with cached credential data:

bash
# Remove existing credentials
eas credentials:remove

# Re-upload fresh credentials
eas credentials:import --path credentials.json

Creating Proper .p12 Files on Different Platforms

The macOS Method (Recommended)

The only reliable way to create iOS distribution certificates is on a Mac with proper Apple Developer account access:

  1. Open Keychain Access on the collaborator’s Mac
  2. Go to Keychain Access → Certificate Assistant → Request a Certificate from a Certificate Authority
  3. Fill in your email and select “Saved to disk”
  4. Once approved, export the certificate as a .p12 file from Keychain Access
  5. Use the default Keychain Access export options (include private key, use strong password)

Windows Workaround (Not Recommended)

If you absolutely must use Windows:

  1. Install OpenSSL for Windows
  2. Use these exact commands:
bash
# Convert certificate to PEM format
openssl pkcs12 -in certificate.p12 -out certificate.pem -nodes -passin pass:your_password

# Create new PKCS12 with proper headers
openssl pkcs12 -export -out certificate_fixed.p12 -inkey certificate.pem -in certificate.pem -password pass:your_new_password
  1. Test thoroughly before using with EAS

Certificate Validation Script

Create this script to validate your certificate before uploading:

bash
#!/bin/bash
# certificate_check.sh

CERT_FILE="$1"
PASSWORD="$2"

echo "Checking certificate format..."
openssl pkcs12 -in "$CERT_FILE" -passin pass:"$PASSWORD" -nokeys -out /tmp/cert.pem

echo "Certificate details:"
openssl x509 -in /tmp/cert.pem -text -noout | grep -E "(Subject:|Issuer:|X509v3 Key Usage:|X509v3 Extended Key Usage:)"

echo "Certificate fingerprint:"
openssl x509 -in /tmp/cert.pem -noout -fingerprint -sha1

echo "Checking certificate chain..."
openssl verify -CAfile /tmp/cert.pem /tmp/cert.pem

EAS Configuration and Credential Management

Proper credentials.json Structure

Ensure your credentials.json follows this exact structure:

json
{
  "ios": {
    "distributionCertificate": {
      "filename": "distribution.p12",
      "password": "your_certificate_password",
      "id": "your_certificate_id",
      "teamId": "your_team_id"
    },
    "provisioningProfile": {
      "filename": "profile.mobileprovision",
      "id": "your_profile_id"
    }
  }
}

Environment-Specific Credentials

Consider using different credentials for development vs. distribution:

bash
# For development builds
eas build --platform ios --profile development

# For distribution builds
eas build --platform ios --profile distribution

Credential Rotation Strategy

Apple certificates expire annually. Implement a rotation strategy:

  1. 60 days before expiration: Notify team
  2. 30 days before expiration: Generate new certificates
  3. 7 days before expiration: Test new credentials
  4. Day of expiration: Switch to new credentials

Advanced Verification Techniques

Certificate Chain Verification

Verify your certificate has the proper chain:

bash
# Check certificate chain
openssl x509 -in your_cert.p12 -noout -text | grep -A 10 "Authority Information Access"

Look for Apple root certificates in the chain.

Provisioning Profile Analysis

Deep-dive into your provisioning profile:

bash
# Extract profile details
security cms -D -i profile.mobileprovision > profile.plist

# Check profile contents
cat profile.plist | grep -E "(application-identifier|provisioned-profiles|entitlements)"

EAS Build Log Analysis

Examine the full EAS build log for more detailed error information:

bash
eas build --platform ios --local --log-format raw

Look for specific error codes and timestamps around the certificate validation step.

Preventative Measures for Future Builds

Automated Certificate Monitoring

Set up monitoring for certificate expiration:

bash
#!/bin/bash
# check_cert_expiration.sh

openssl x509 -in cert.p12 -noout -enddate | cut -d= -f2

Run this weekly and send alerts if expiration is within 60 days.

Centralized Credential Management

Consider using a secure credential management system:

  • HashiCorp Vault
  • AWS Secrets Manager
  • GitHub Secrets (for smaller teams)

Build Environment Standardization

Standardize your build process:

  • Use macOS-based CI/CD pipelines
  • Implement certificate signing scripts
  • Maintain documentation for credential procedures

Regular Credential Audits

Conduct quarterly audits of:

  • Certificate validity
  • Profile-app certificate matching
  • Team member access permissions
  • Security of credential storage

Sources

  1. Expo EAS Build Documentation - iOS Configuration
  2. Apple Developer Documentation - Distribution Certificate Creation
  3. OpenSSL Certificate Management Guide
  4. React Native iOS Build Best Practices
  5. EAS Troubleshooting Guide - Certificate Issues

Conclusion

The “Distribution certificate hasn’t been imported successfully” error is most likely caused by either a certificate-provisioning profile mismatch or the Windows-generated .p12 file lacking proper iOS certificate attributes. Recreating the .p12 file on a macOS device using Keychain Access is strongly recommended as the Windows OpenSSL method often produces certificates that Apple’s systems reject.

Start by verifying certificate fingerprints and testing with direct Xcode builds before attempting EAS again. Implement proper credential management practices to prevent similar issues in the future, and always use macOS for iOS certificate creation and management. If your collaborator can regenerate the credentials on their Mac, this will likely resolve the issue immediately.