diff --git a/lib/src/apple/p12.dart b/lib/src/apple/p12.dart index 84b5582..225099f 100644 --- a/lib/src/apple/p12.dart +++ b/lib/src/apple/p12.dart @@ -2,8 +2,11 @@ import 'dart:io'; import 'package:dcli/dcli.dart'; -P12CertificateInfo readP12CertificateInfo(File certificate) { - final certInfo = _opensslPkcs12(certificate); +P12CertificateInfo readP12CertificateInfo( + File certificate, { + String? password, +}) { + final certInfo = _opensslPkcs12(certificate, password: password); final friendlyNameRegEx = RegExp('friendlyName: (.*)'); final friendlyName = friendlyNameRegEx.firstMatch(certInfo)?.group(1); @@ -15,9 +18,9 @@ P12CertificateInfo readP12CertificateInfo(File certificate) { ); } -String _opensslPkcs12(File certificate) { +String _opensslPkcs12(File certificate, {String? password}) { final command = - 'openssl pkcs12 -info -in ${certificate.absolute.path} -clcerts -nokeys -passin pass:'; + 'openssl pkcs12 -info -in ${certificate.absolute.path} -clcerts -nokeys -passin pass:${password ?? ''}'; final normalProgress = Progress.capture(); try { diff --git a/lib/src/build_ipa.dart b/lib/src/build_ipa.dart index 9ae6e0e..7f7c9a9 100644 --- a/lib/src/build_ipa.dart +++ b/lib/src/build_ipa.dart @@ -24,6 +24,7 @@ import 'package:sidekick_core/sidekick_core.dart'; /// a [XcodeBuildArchiveTimeoutException] is thrown. File buildIpa({ required File certificate, + String? certificatePassword, required ProvisioningProfile provisioningProfile, required ExportMethod method, required String bundleIdentifier, @@ -39,7 +40,8 @@ File buildIpa({ final project = package ?? mainProject!; installProvisioningProfile(provisioningProfile); - final certificateInfo = readP12CertificateInfo(certificate); + final certificateInfo = + readP12CertificateInfo(certificate, password: certificatePassword); final keyChain = () { final bool isCi = env['CI'] == 'true'; @@ -50,7 +52,7 @@ File buildIpa({ } return Keychain.login(); }(); - keyChain.addPkcs12Certificate(certificate); + keyChain.addPkcs12Certificate(certificate, password: certificatePassword); keyChain.unlock(); print('Building the ${project.name} iOS app using:');