Skip to content

Commit 70c9216

Browse files
benbfacebook-github-bot
authored andcommitted
--no-check-certificates option for codesign_bundle
Summary: We want to reuse this code to select a profile before signing, for use in Orchard. This diff allows disabling the check on installed certs (assuming the enterprise certs are not installed on CI macs). Reviewed By: milend Differential Revision: D83574802 fbshipit-source-id: f4c983cf84909747a0e4c916597e10bd463e0e60
1 parent 1315301 commit 70c9216

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

prelude/apple/tools/code_signing/codesign_bundle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def _select_provisioning_profile(
109109
should_use_fast_provisioning_profile_parsing: bool,
110110
strict_provisioning_profile_search: bool,
111111
provisioning_profile_filter: Optional[str],
112+
no_check_certificates: bool = False,
112113
log_file_path: Optional[Path] = None,
113114
) -> SelectedProvisioningProfileInfo:
114115
read_provisioning_profile_command_factory = (
@@ -150,6 +151,7 @@ def _select_provisioning_profile(
150151
platform,
151152
strict_provisioning_profile_search,
152153
provisioning_profile_filter,
154+
no_check_certificates,
153155
)
154156
if selected_profile_info is None:
155157
if not mismatches:
@@ -201,6 +203,7 @@ def signing_context_with_profile_selection(
201203
should_use_fast_provisioning_profile_parsing: bool = False,
202204
strict_provisioning_profile_search: bool = False,
203205
provisioning_profile_filter: Optional[str] = None,
206+
no_check_certificates: bool = False,
204207
) -> SigningContextWithProfileSelection:
205208
with open(info_plist_source, mode="rb") as info_plist_file:
206209
info_plist_metadata = InfoPlistMetadata.from_file(info_plist_file)
@@ -214,6 +217,7 @@ def signing_context_with_profile_selection(
214217
should_use_fast_provisioning_profile_parsing=should_use_fast_provisioning_profile_parsing,
215218
strict_provisioning_profile_search=strict_provisioning_profile_search,
216219
provisioning_profile_filter=provisioning_profile_filter,
220+
no_check_certificates=no_check_certificates,
217221
)
218222

219223
return SigningContextWithProfileSelection(

prelude/apple/tools/code_signing/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Arguments(Tap):
4545
strict_provisioning_profile_search: bool = False
4646
provisioning_profile_filter: Optional[str] = None
4747
only_select_provisioning_profile: bool = False
48+
no_check_certificates: bool = False
4849

4950
def configure(self) -> None:
5051
"""
@@ -131,6 +132,12 @@ def configure(self) -> None:
131132
required=False,
132133
help="Skip codesigning and just output the path to the selected provisioning profile to stdout.",
133134
)
135+
self.add_argument(
136+
"--no-check-certificates",
137+
action="store_true",
138+
required=False,
139+
help="Skip the check on code signing identities when selecting provisioning profile.",
140+
)
134141

135142

136143
# Add emoji to beginning of actionable error message so it stands out more.
@@ -164,6 +171,7 @@ def _main() -> None:
164171
should_use_fast_provisioning_profile_parsing=args.fast_provisioning_profile_parsing,
165172
strict_provisioning_profile_search=args.strict_provisioning_profile_search,
166173
provisioning_profile_filter=args.provisioning_profile_filter,
174+
no_check_certificates=args.no_check_certificates,
167175
)
168176

169177
if args.only_select_provisioning_profile:

prelude/apple/tools/code_signing/provisioning_profile_selection.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def select_best_provisioning_profile(
195195
platform: ApplePlatform,
196196
strict_search: bool,
197197
provisioning_profile_filter: Optional[str],
198+
no_check_certificates: bool = False,
198199
) -> Tuple[
199200
Optional[SelectedProvisioningProfileInfo], List[IProvisioningProfileDiagnostics]
200201
]:
@@ -286,14 +287,20 @@ def log_mismatched_profile(mismatch: IProvisioningProfileDiagnostics) -> None:
286287
log_mismatched_profile(cast(EntitlementsMismatch, mismatch))
287288
continue
288289

289-
certificate, mismatch = _check_developer_certificates_match(
290-
profile=profile,
291-
identities=code_signing_identities,
292-
bundle_id_match_length=current_match_length,
293-
)
294-
if not certificate:
295-
log_mismatched_profile(cast(DeveloperCertificateMismatch, mismatch))
296-
continue
290+
if no_check_certificates:
291+
certificate = CodeSigningIdentity(
292+
fingerprint=next(iter(profile.developer_certificate_fingerprints)),
293+
subject_common_name="Unknown",
294+
)
295+
else:
296+
certificate, mismatch = _check_developer_certificates_match(
297+
profile=profile,
298+
identities=code_signing_identities,
299+
bundle_id_match_length=current_match_length,
300+
)
301+
if not certificate:
302+
log_mismatched_profile(cast(DeveloperCertificateMismatch, mismatch))
303+
continue
297304

298305
_LOGGER.info(
299306
f"Matching provisioning profile `{profile.file_path.name}` with score {current_match_length}"

0 commit comments

Comments
 (0)