Skip to content

Commit

Permalink
New Store Build: 1.4.5-RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
icodesign committed Aug 2, 2016
1 parent b4cdf35 commit f0cde2b
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ public struct AppEnv {
}

private static var isAppStoreReceiptSandbox: Bool {
return NSBundle.mainBundle().appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
let b = NSBundle.mainBundle().appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
NSLog("isAppStoreReceiptSandbox: \(b)")
return b
}

private static var hasEmbeddedMobileProvision: Bool {
return NSBundle.mainBundle().pathForResource("embedded", ofType: "mobileprovision") != nil
let b = NSBundle.mainBundle().pathForResource("embedded", ofType: "mobileprovision") != nil
NSLog("hasEmbeddedMobileProvision: \(b)")
return b
}

}
2 changes: 1 addition & 1 deletion PacketProcessor/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion PacketTunnel/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
32 changes: 16 additions & 16 deletions Potatso.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3443,10 +3443,10 @@
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -3475,10 +3475,10 @@
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -3507,11 +3507,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = PotatsoBase/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -3534,10 +3534,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = PotatsoBase/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -3560,11 +3560,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -3593,10 +3593,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -3623,11 +3623,11 @@
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down Expand Up @@ -3664,10 +3664,10 @@
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 114;
CURRENT_PROJECT_VERSION = 115;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 114;
DYLIB_CURRENT_VERSION = 115;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down
2 changes: 1 addition & 1 deletion Potatso/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
22 changes: 10 additions & 12 deletions Potatso/Utils/Receipt.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,14 @@ @implementation ReceiptUtils

+ (BOOL)verifyReceiptAtPath: (NSString *)receiptPath {
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSLog(@"verifyReceiptAtPath: %@ bundleIdentifier: %@", receiptPath, bundleIdentifier);
NSDictionary *receipt = [self dictionaryWithAppStoreReceipt:receiptPath];
NSLog(@"verifyReceiptAtPath receipt dictionary: %@", receipt);

if (!receipt) {
return NO;
}

unsigned char uuidBytes[16];
NSUUID *vendorUUID = [[UIDevice currentDevice] identifierForVendor];
[vendorUUID getUUIDBytes:uuidBytes];

NSMutableData *input = [NSMutableData data];
[input appendBytes:uuidBytes length:sizeof(uuidBytes)];
[input appendData:[receipt objectForKey:kReceiptOpaqueValue]];
[input appendData:[receipt objectForKey:kReceiptBundleIdentifierData]];

NSMutableData *hash = [NSMutableData dataWithLength:SHA_DIGEST_LENGTH];
SHA1([input bytes], [input length], [hash mutableBytes]);

if ([bundleIdentifier isEqualToString:[receipt objectForKey:kReceiptBundleIdentifier]]) {
return YES;
}
Expand All @@ -70,6 +60,8 @@ + (BOOL)verifyReceiptAtPath: (NSString *)receiptPath {
+ (NSDictionary *)dictionaryWithAppStoreReceipt: (NSString *)receiptPath {
NSData * rootCertData = [self appleRootCert];

NSLog(@"dictionaryWithAppStoreReceipt rootCertData len: %d", rootCertData.length);

ERR_load_PKCS7_strings();
ERR_load_X509_strings();
OpenSSL_add_all_digests();
Expand All @@ -81,6 +73,7 @@ + (NSDictionary *)dictionaryWithAppStoreReceipt: (NSString *)receiptPath {
const char * path = [[receiptPath stringByStandardizingPath] fileSystemRepresentation];
FILE *fp = fopen(path, "rb");
if (fp == NULL) {
NSLog(@"dictionaryWithAppStoreReceipt open receiptPath fail: %@", receiptPath);
return nil;
}

Expand All @@ -89,15 +82,18 @@ + (NSDictionary *)dictionaryWithAppStoreReceipt: (NSString *)receiptPath {

// Check if the receipt file was invalid (otherwise we go crashing and burning)
if (p7 == NULL) {
NSLog(@"dictionaryWithAppStoreReceipt p7 null");
return nil;
}

if (!PKCS7_type_is_signed(p7)) {
NSLog(@"dictionaryWithAppStoreReceipt PKCS7_type_is_signed fail");
PKCS7_free(p7);
return nil;
}

if (!PKCS7_type_is_data(p7->d.sign->contents)) {
NSLog(@"dictionaryWithAppStoreReceipt PKCS7_type_is_data fail");
PKCS7_free(p7);
return nil;
}
Expand Down Expand Up @@ -126,6 +122,7 @@ + (NSDictionary *)dictionaryWithAppStoreReceipt: (NSString *)receiptPath {

if (verifyReturnValue != 1) {
PKCS7_free(p7);
NSLog(@"dictionaryWithAppStoreReceipt verifyReturnValue fail");
return nil;
}

Expand All @@ -140,6 +137,7 @@ + (NSDictionary *)dictionaryWithAppStoreReceipt: (NSString *)receiptPath {
ASN1_get_object(&p, &length, &type, &xclass, end - p);
if (type != V_ASN1_SET) {
PKCS7_free(p7);
NSLog(@"dictionaryWithAppStoreReceipt type fail");
return nil;
}

Expand Down
39 changes: 24 additions & 15 deletions Potatso/Utils/Receipt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ class Receipt: NSObject, SKRequestDelegate {

func validate() {
if AppEnv.isTestFlight {
NSLog("isTestFlight")
if !validateKeychainAppStore() {
NSLog("validateKeychainAppStore fail")
failAndTerminate()
}
} else if AppEnv.isAppStore {
}
if AppEnv.isAppStore {
NSLog("isAppStore")
if isStoreReceiptValidate() {
NSLog("isStoreReceiptValidate true")
markKeychainAppStore()
} else {
NSLog("isStoreReceiptValidate false")
failAndTerminate()
}
}
Expand All @@ -37,14 +43,17 @@ class Receipt: NSObject, SKRequestDelegate {
}

private func validateKeychainAppStore() -> Bool {
NSLog("validateKeychainAppStore")
if let value = keychain["appstore"] {
NSLog("keychain value: \(value)")
return value == "true"
}
return false
}

private func isStoreReceiptValidate() -> Bool {
guard let receiptPath = NSBundle.mainBundle().appStoreReceiptURL?.path where NSFileManager.defaultManager().fileExistsAtPath(receiptPath) else {
NSLog("isStoreReceiptValidate can't find appStoreReceiptURL")
return false
}
return ReceiptUtils.verifyReceiptAtPath(receiptPath)
Expand All @@ -69,20 +78,20 @@ class Receipt: NSObject, SKRequestDelegate {
}

private func failAndTerminate() {
dispatch_async(dispatch_get_main_queue()) {
guard let vc = UIApplication.sharedApplication().keyWindow?.rootViewController else {
return
}
Alert.show(vc, title: "Receipt Validation Error".localized(), message: "The app is only made for App Store users. Please try again.".localized(), confirmMessage: "CANCEL".localized(), confirmCallback: {
logEvent(.ReceiptValidationCancel, attributes: nil)
self.terminate()
}, cancelMessage: "BUY".localized()) {
logEvent(.ReceiptValidationBuy, attributes: nil)
Appirater.rateApp()
self.terminate()
}

}
// dispatch_async(dispatch_get_main_queue()) {
// guard let vc = UIApplication.sharedApplication().keyWindow?.rootViewController else {
// return
// }
// Alert.show(vc, title: "Receipt Validation Error".localized(), message: "The app is only made for App Store users. Please try again.".localized(), confirmMessage: "CANCEL".localized(), confirmCallback: {
// logEvent(.ReceiptValidationCancel, attributes: nil)
// self.terminate()
// }, cancelMessage: "BUY".localized()) {
// logEvent(.ReceiptValidationBuy, attributes: nil)
// Appirater.rateApp()
// self.terminate()
// }
//
// }
}

private func terminate() {
Expand Down
2 changes: 1 addition & 1 deletion PotatsoBase/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion PotatsoLibrary/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion PotatsoLibraryTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion PotatsoModel/BaseModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import RealmSwift
import PotatsoBase

private let version: UInt64 = 10
private let version: UInt64 = 11
public var defaultRealm = try! Realm()

public func setupDefaultReaml() {
Expand Down
2 changes: 1 addition & 1 deletion PotatsoModel/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion PotatsoTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion TodayWidget/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down

0 comments on commit f0cde2b

Please sign in to comment.