Fastlane is the industry standard for automating iOS and Android releases. However, storing App Store credentials, keystore passwords, and certificates on CI/CD runners poses significant security risks. Here is how to lock down your Fastlane credentials using Match, Google Cloud Storage, and ephemeral keys.
Use Fastlane Match for Certificates
Do not store certificates in your repository or upload them manually. Use Fastlane Match, which encrypts your distribution certificates and provisioning profiles using a passphrase, storing them securely in a private Git repository or Google Cloud storage bucket.
To initialize Match with a secure Google Cloud bucket:
# Fastfile configuration
lane :sync_certificates do
match(
type: "appstore",
storage_mode: "gc_storage",
google_cloud_bucket_name: "venelx-signing-keys",
google_cloud_keys_file: "./gcp-key.json",
readonly: true
)
end
App Store Connect API Authentication
Avoid using Apple ID credentials with 2FA in CI, as the sessions expire frequently. Instead, create an App Store Connect API Key in the Apple Developer Portal and feed it directly to Fastlane:
# Fastfile Connect API Auth
lane :release_to_store do
api_key = app_store_connect_api_key(
key_id: ENV["APPLE_API_KEY_ID"],
issuer_id: ENV["APPLE_ISSUER_ID"],
key_content: ENV["APPLE_API_KEY_CONTENT"],
is_key_content_base64: true
)
deliver(api_key: api_key)
end
This configuration ensures that your build pipeline never prompts for verification codes or passwords.
Cleanup Routines in CI Pipelines
In headless sandboxes, you must ensure that all certificates are shredded immediately after building to prevent subsequent jobs from accessing them. Here is a simple cleanup command sequences to place in your runner scripts:
# Shred and delete sensitive certs
shred -u -n 3 ./gcp-key.json
security delete-keychain build.keychain
By coupling Fastlane with isolated sandbox environments, you ensure that keys are completely wiped from RAM. Read about our approach to platform security in Venelx Security Disclaimers.
References & Citations
- Fastlane match secrets: Fastlane Tools
- Apple App Store API Keys: Developer Portal Support
- Headless iOS signing guide: iOS Code Signing Tutorial