@@ -573,10 +573,11 @@ - (void)checkExpectedBundleID {
573
573
#pragma mark - private - App ID Validation
574
574
575
575
/* *
576
- * Validates the format and fingerprint of the app ID contained in GOOGLE_APP_ID in the plist file.
577
- * This is the main method for validating app ID.
576
+ * Validates the format of app ID and its included bundle ID hash contained in GOOGLE_APP_ID in the
577
+ * plist file. This is the main method for validating app ID.
578
578
*
579
- * @return YES if the app ID fulfills the expected format and fingerprint, NO otherwise.
579
+ * @return YES if the app ID fulfills the expected format and contains a hashed bundle ID, NO
580
+ * otherwise.
580
581
*/
581
582
- (BOOL )isAppIDValid {
582
583
NSString *appID = _options.googleAppID ;
@@ -597,7 +598,7 @@ - (BOOL)isAppIDValid {
597
598
598
599
+ (BOOL )validateAppID : (NSString *)appID {
599
600
// Failing validation only occurs when we are sure we are looking at a V2 app ID and it does not
600
- // have a valid fingerprint , otherwise we just warn about the potential issue.
601
+ // have a valid hashed bundle ID , otherwise we just warn about the potential issue.
601
602
if (!appID.length ) {
602
603
return NO ;
603
604
}
@@ -627,7 +628,7 @@ + (BOOL)validateAppID:(NSString *)appID {
627
628
return NO ;
628
629
}
629
630
630
- if (![self validateAppIDFingerprint : appID withVersion : appIDVersion]) {
631
+ if (![self validateBundleIDHashWithinAppID : appID forVersion : appIDVersion]) {
631
632
return NO ;
632
633
}
633
634
@@ -643,7 +644,7 @@ + (NSString *)actualBundleID {
643
644
* The version must end in ":".
644
645
*
645
646
* For v1 app ids the format is expected to be
646
- * '<version #>:<project number>:ios:<fingerprint of bundle id>'.
647
+ * '<version #>:<project number>:ios:<hashed bundle id>'.
647
648
*
648
649
* This method does not verify that the contents of the app id are correct, just that they fulfill
649
650
* the expected format.
@@ -661,36 +662,36 @@ + (BOOL)validateAppIDFormat:(NSString *)appID withVersion:(NSString *)version {
661
662
stringScanner.charactersToBeSkipped = nil ;
662
663
663
664
// Skip version part
664
- // '*<version #>*:<project number>:ios:<fingerprint of bundle id>'
665
+ // '*<version #>*:<project number>:ios:<hashed bundle id>'
665
666
if (![stringScanner scanString: version intoString: NULL ]) {
666
667
// The version part is missing or mismatched
667
668
return NO ;
668
669
}
669
670
670
671
// Validate version part (see part between '*' symbols below)
671
- // '<version #>*:*<project number>:ios:<fingerprint of bundle id>'
672
+ // '<version #>*:*<project number>:ios:<hashed bundle id>'
672
673
if (![stringScanner scanString: @" :" intoString: NULL ]) {
673
674
// appIDVersion must be separated by ":"
674
675
return NO ;
675
676
}
676
677
677
678
// Validate version part (see part between '*' symbols below)
678
- // '<version #>:*<project number>*:ios:<fingerprint of bundle id>'.
679
+ // '<version #>:*<project number>*:ios:<hashed bundle id>'.
679
680
NSInteger projectNumber = NSNotFound ;
680
681
if (![stringScanner scanInteger: &projectNumber]) {
681
682
// NO project number found.
682
683
return NO ;
683
684
}
684
685
685
686
// Validate version part (see part between '*' symbols below)
686
- // '<version #>:<project number>*:*ios:<fingerprint of bundle id>'.
687
+ // '<version #>:<project number>*:*ios:<hashed bundle id>'.
687
688
if (![stringScanner scanString: @" :" intoString: NULL ]) {
688
689
// The project number must be separated by ":"
689
690
return NO ;
690
691
}
691
692
692
693
// Validate version part (see part between '*' symbols below)
693
- // '<version #>:<project number>:*ios*:<fingerprint of bundle id>'.
694
+ // '<version #>:<project number>:*ios*:<hashed bundle id>'.
694
695
NSString *platform;
695
696
if (![stringScanner scanUpToString: @" :" intoString: &platform]) {
696
697
return NO ;
@@ -702,57 +703,57 @@ + (BOOL)validateAppIDFormat:(NSString *)appID withVersion:(NSString *)version {
702
703
}
703
704
704
705
// Validate version part (see part between '*' symbols below)
705
- // '<version #>:<project number>:ios*:*<fingerprint of bundle id>'.
706
+ // '<version #>:<project number>:ios*:*<hashed bundle id>'.
706
707
if (![stringScanner scanString: @" :" intoString: NULL ]) {
707
708
// The platform must be separated by ":"
708
709
return NO ;
709
710
}
710
711
711
712
// Validate version part (see part between '*' symbols below)
712
- // '<version #>:<project number>:ios:*<fingerprint of bundle id>*'.
713
- unsigned long long fingerprint = NSNotFound ;
714
- if (![stringScanner scanHexLongLong: &fingerprint ]) {
715
- // Fingerprint part is missing
713
+ // '<version #>:<project number>:ios:*<hashed bundle id>*'.
714
+ unsigned long long bundleIDHash = NSNotFound ;
715
+ if (![stringScanner scanHexLongLong: &bundleIDHash ]) {
716
+ // Hashed bundleID part is missing
716
717
return NO ;
717
718
}
718
719
719
720
if (!stringScanner.isAtEnd ) {
720
- // There are not allowed characters in the fingerprint part
721
+ // There are not allowed characters in the hashed bundle ID part
721
722
return NO ;
722
723
}
723
724
724
725
return YES ;
725
726
}
726
727
727
728
/* *
728
- * Validates that the fingerprint of the app ID string is what is expected based on the supplied
729
- * version.
729
+ * Validates that the hashed bundle ID included in the app ID string is what is expected based on
730
+ * the supplied version.
730
731
*
731
732
* Note that the v1 hash algorithm is not permitted on the client and cannot be fully validated.
732
733
*
733
734
* @param appID Contents of GOOGLE_APP_ID from the plist file.
734
735
* @param version Indicates what version of the app id format this string should be.
735
- * @return YES if provided string fufills the expected fingerprint and the version is known, NO
736
+ * @return YES if provided string fufills the expected hashed bundle ID and the version is known, NO
736
737
* otherwise.
737
738
*/
738
- + (BOOL )validateAppIDFingerprint : (NSString *)appID withVersion : (NSString *)version {
739
- // Extract the supplied fingerprint from the supplied app ID.
740
- // This assumes the app ID format is the same for all known versions below. If the app ID format
741
- // changes in future versions, the tokenizing of the app ID format will need to take into account
742
- // the version of the app ID.
739
+ + (BOOL )validateBundleIDHashWithinAppID : (NSString *)appID forVersion : (NSString *)version {
740
+ // Extract the hashed bundle ID from the given app ID.
741
+ // This assumes the app ID format is the same for all known versions below.
742
+ // If the app ID format changes in future versions, the tokenizing of the app
743
+ // ID format will need to take into account the version of the app ID.
743
744
NSArray *components = [appID componentsSeparatedByString: @" :" ];
744
745
if (components.count != 4 ) {
745
746
return NO ;
746
747
}
747
748
748
- NSString *suppliedFingerprintString = components[3 ];
749
- if (!suppliedFingerprintString .length ) {
749
+ NSString *suppliedBundleIDHashString = components[3 ];
750
+ if (!suppliedBundleIDHashString .length ) {
750
751
return NO ;
751
752
}
752
753
753
- uint64_t suppliedFingerprint ;
754
- NSScanner *scanner = [NSScanner scannerWithString: suppliedFingerprintString ];
755
- if (![scanner scanHexLongLong: &suppliedFingerprint ]) {
754
+ uint64_t suppliedBundleIDHash ;
755
+ NSScanner *scanner = [NSScanner scannerWithString: suppliedBundleIDHashString ];
756
+ if (![scanner scanHexLongLong: &suppliedBundleIDHash ]) {
756
757
return NO ;
757
758
}
758
759
0 commit comments