@@ -31,7 +31,7 @@ + (NSString*) computeThumbprint:(NSData*) certificateData{
3131
3232 // compute SHA-1 thumbprint
3333 unsigned char sha1Buffer[CC_SHA1_DIGEST_LENGTH];
34- CC_SHA1 (certificateData.bytes , certificateData.length , sha1Buffer);
34+ CC_SHA1 (certificateData.bytes , (CC_LONG) certificateData.length , sha1Buffer);
3535 NSMutableString *fingerprint = [NSMutableString stringWithCapacity: CC_SHA1_DIGEST_LENGTH * 3 ];
3636 for (int i = 0 ; i < CC_SHA1_DIGEST_LENGTH; ++i)
3737 {
@@ -79,11 +79,15 @@ + (NSString*) createDeviceAuthResponse:(NSString*) authorizationServer
7979+ (NSString *) getOrgUnitFromIssuer : (NSString *) issuer {
8080 NSString *regexString = @" [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" ;
8181 NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: regexString options: 0 error: NULL ];
82- NSTextCheckingResult * matches = (NSTextCheckingResult *)[regex matchesInString: issuer options: 0 range: NSMakeRange (0 , [issuer length ])];
83- for (NSTextCheckingResult * match in matches)
84- {
85- return [NSString stringWithFormat: @" OU=%@ " , [issuer substringWithRange: match.range]];
82+
83+ for (NSTextCheckingResult * myMatch in [regex matchesInString: issuer options: 0 range: NSMakeRange (0 , [issuer length ])]){
84+ for (NSUInteger i = 0 ; i < myMatch.numberOfRanges ; ++i)
85+ {
86+ NSRange matchedRange = [myMatch rangeAtIndex: i];
87+ return [NSString stringWithFormat: @" OU=%@ " , [issuer substringWithRange: matchedRange]];
88+ }
8689 }
90+
8791 return nil ;
8892}
8993
@@ -93,14 +97,18 @@ + (BOOL) isValidIssuer:(NSString*) certAuths
9397 keychainCertIssuer = [keychainCertIssuer uppercaseString ];
9498 certAuths = [certAuths uppercaseString ];
9599 NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: regexString options: 0 error: NULL ];
96- NSTextCheckingResult * matches = (NSTextCheckingResult *)[regex matchesInString: certAuths options: 0 range: NSMakeRange (0 , [certAuths length ])];
97- for (NSTextCheckingResult *match in matches)
98- {
99- NSString *text = [certAuths substringWithRange: match.range];
100- if ([NSString adSame: text toString: keychainCertIssuer]){
101- return true ;
100+
101+ for (NSTextCheckingResult * myMatch in [regex matchesInString: certAuths options: 0 range: NSMakeRange (0 , [certAuths length ])]){
102+ for (NSUInteger i = 0 ; i < myMatch.numberOfRanges ; ++i)
103+ {
104+ NSRange matchedRange = [myMatch rangeAtIndex: i];
105+ NSString *text = [certAuths substringWithRange: matchedRange];
106+ if ([NSString adSame: text toString: keychainCertIssuer]){
107+ return true ;
108+ }
102109 }
103110 }
111+
104112 return false ;
105113}
106114
0 commit comments