Skip to content

Commit

Permalink
Workaround JIT-less setup not being able to find certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Apr 21, 2024
1 parent e8b3ea8 commit b5b44e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions LCJITLessSetupViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ - (void)loadView {
self.view.backgroundColor = UIColor.systemBackgroundColor;
self.title = @"LiveContainer JIT-less setup";

if (![LCUtils sidestoreKeychainItem:@"signingCertificate"]) {
NSData *certData = [LCUtils keychainItem:@"signingCertificate" ofStore:@"com.SideStore.SideStore"];
if (!certData) {
certData = [LCUtils keychainItem:@"signingCertificate" ofStore:@"com.rileytestut.AltStore"];
}
if (!certData) {
[self showDialogTitle:@"Error" message:@"Failed to find certificate" handler:nil];
return;
}

[LCUtils updateCertificate];
LCUtils.certificateData = certData;
[LCUtils changeMainExecutableTo:@"LiveContainer_PleaseDoNotShortenTheExecutableNameBecauseItIsUsedToReserveSpaceForOverwritingThankYou"];

NSError *error;
Expand Down
4 changes: 2 additions & 2 deletions LCUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
@interface LCUtils : NSObject

+ (NSData *)certificateData;
+ (void)updateCertificate;
+ (void)setCertificateData:(NSData *)certData;

+ (NSData *)sidestoreKeychainItem:(NSString *)key;
+ (NSData *)keychainItem:(NSString *)key ofStore:(NSString *)store;
+ (NSProgress *)signAppBundle:(NSString *)path completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;

+ (BOOL)isAppGroupSideStore;
Expand Down
8 changes: 4 additions & 4 deletions LCUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ @implementation LCUtils

#pragma mark Certificate password

+ (NSData *)sidestoreKeychainItem:(NSString *)key {
+ (NSData *)keychainItem:(NSString *)key ofStore:(NSString *)store {
NSDictionary *dict = @{
(id)kSecClass: (id)kSecClassGenericPassword,
(id)kSecAttrService: @"com.SideStore.SideStore",
(id)kSecAttrService: store,
(id)kSecAttrAccount: key,
(id)kSecAttrSynchronizable: (id)kSecAttrSynchronizableAny,
(id)kSecMatchLimit: (id)kSecMatchLimitOne,
Expand All @@ -28,8 +28,8 @@ + (NSData *)sidestoreKeychainItem:(NSString *)key {
}
}

+ (void)updateCertificate {
[NSUserDefaults.standardUserDefaults setObject:[self sidestoreKeychainItem:@"signingCertificate"] forKey:@"LCCertificateData"];
+ (void)setCertificateData:(NSData *)certData {
[NSUserDefaults.standardUserDefaults setObject:certData forKey:@"LCCertificateData"];
}

+ (NSData *)certificateData {
Expand Down

0 comments on commit b5b44e1

Please sign in to comment.