Skip to content

Commit

Permalink
Add certificatePassword to buildIpa
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Nov 4, 2024
1 parent 1390f10 commit a50c828
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/src/apple/p12.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions lib/src/build_ipa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand All @@ -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:');
Expand Down

0 comments on commit a50c828

Please sign in to comment.