251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
+
-
+
+
-
+
+
-
+
|
}
- (BOOL)hasCommonNameMatchingDomain: (OFString*)domain
{
OFString *name;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFList *CNs = [[self subject] objectForKey: OID_commonName];
OFEnumerator *enumerator = [CNs objectEnumerator];
for (name in CNs) {
while ((name = [enumerator nextObject]) != nil) {
if ([self X509_isAssertedDomain: name
equalDomain: domain]) {
[pool release];
return YES;
}
}
[pool release];
return NO;
}
- (BOOL)hasDNSNameMatchingDomain: (OFString*)domain
{
OFString *name;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDictionary *SANs = [self subjectAlternativeName];
OFList *assertedNames = [SANs objectForKey: @"dNSName"];
OFEnumerator *enumerator = [assertedNames objectEnumerator];
for (name in assertedNames) {
while ((name = [enumerator nextObject]) != nil) {
if ([self X509_isAssertedDomain: name
equalDomain: domain]) {
[pool release];
return YES;
}
}
[pool release];
return NO;
}
- (BOOL)hasSRVNameMatchingDomain: (OFString*)domain
service: (OFString*)service
{
size_t serviceLength;
OFString *name;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDictionary *SANs = [self subjectAlternativeName];
OFList *assertedNames = [[SANs objectForKey: @"otherName"]
objectForKey: OID_SRVName];
OFEnumerator *enumerator = [assertedNames objectEnumerator];
if (![service hasPrefix: @"_"])
service = [service stringByPrependingString: @"_"];
service = [service stringByAppendingString: @"."];
serviceLength = [service length];
for (name in assertedNames) {
while ((name = [enumerator nextObject]) != nil) {
if ([name hasPrefix: service]) {
OFString *asserted;
asserted = [name substringWithRange: of_range(
serviceLength, [name length] - serviceLength)];
if ([self X509_isAssertedDomain: asserted
equalDomain: domain]) {
[pool release];
|