4848
4949#import < ObjFW/macros.h>
5050
51+ OF_ASSUME_NONNULL_BEGIN
52+
53+ @interface X509Certificate ()
54+ - (bool )X509_isAssertedDomain : (OFString *)asserted
55+ equalDomain : (OFString *)domain ;
56+ - (OFDictionary *)X509_dictionaryFromX509Name : (X509_NAME *)name ;
57+ - (X509OID *)X509_stringFromASN1Object : (ASN1_OBJECT *)obj ;
58+ - (OFString *)X509_stringFromASN1String : (ASN1_STRING *)str ;
59+ @end
60+
61+ OF_ASSUME_NONNULL_END
62+
5163@implementation X509Certificate
64+ - init
65+ {
66+ OF_INVALID_INIT_METHOD
67+ }
68+
5269- initWithFile : (OFString *)path
5370{
54- self = [self init ];
71+ self = [super init ];
5572
5673 @try {
5774 OFAutoreleasePool *pool = [[OFAutoreleasePool alloc ] init ];
@@ -75,7 +92,7 @@ @implementation X509Certificate
7592
7693- initWithX509Struct : (X509 *)certificate
7794{
78- self = [self init ];
95+ self = [super init ];
7996
8097 @try {
8198 _certificate = X509_dup (certificate);
@@ -265,12 +282,9 @@ - (OFDictionary *)subjectAlternativeName
265282
266283- (bool )hasCommonNameMatchingDomain : (OFString *)domain
267284{
268- OFString *name;
269285 OFAutoreleasePool *pool = [[OFAutoreleasePool alloc ] init ];
270- OFList *CNs = [[self subject ] objectForKey: OID_commonName];
271- OFEnumerator *enumerator = [CNs objectEnumerator ];
272286
273- while (( name = [enumerator nextObject ]) != nil ) {
287+ for (OFString * name in [[ self subject ] objectForKey: OID_commonName] ) {
274288 if ([self X509_isAssertedDomain: name
275289 equalDomain: domain]) {
276290 [pool release ];
@@ -284,13 +298,10 @@ - (bool)hasCommonNameMatchingDomain: (OFString *)domain
284298
285299- (bool )hasDNSNameMatchingDomain : (OFString *)domain
286300{
287- OFString *name;
288301 OFAutoreleasePool *pool = [[OFAutoreleasePool alloc ] init ];
289- OFDictionary *SANs = [self subjectAlternativeName ];
290- OFList *assertedNames = [SANs objectForKey: @" dNSName" ];
291- OFEnumerator *enumerator = [assertedNames objectEnumerator ];
292302
293- while ((name = [enumerator nextObject ]) != nil ) {
303+ for (OFString *name in
304+ [[self subjectAlternativeName ] objectForKey: @" dNSName" ]) {
294305 if ([self X509_isAssertedDomain: name
295306 equalDomain: domain]) {
296307 [pool release ];
@@ -306,20 +317,18 @@ - (bool)hasSRVNameMatchingDomain: (OFString *)domain
306317 service : (OFString *)service
307318{
308319 size_t serviceLength;
309- OFString *name;
310320 OFAutoreleasePool *pool = [[OFAutoreleasePool alloc ] init ];
311321 OFDictionary *SANs = [self subjectAlternativeName ];
312322 OFList *assertedNames = [[SANs objectForKey: @" otherName" ]
313323 objectForKey: OID_SRVName];
314- OFEnumerator *enumerator = [assertedNames objectEnumerator ];
315324
316325 if (![service hasPrefix: @" _" ])
317326 service = [service stringByPrependingString: @" _" ];
318327
319328 service = [service stringByAppendingString: @" ." ];
320329 serviceLength = [service length ];
321330
322- while (( name = [enumerator nextObject ]) != nil ) {
331+ for (OFString * name in assertedNames ) {
323332 if ([name hasPrefix: service]) {
324333 OFString *asserted;
325334 asserted = [name substringWithRange: of_range (
@@ -443,9 +452,14 @@ - (OFString *)X509_stringFromASN1String: (ASN1_STRING *)str
443452@end
444453
445454@implementation X509OID
455+ - init
456+ {
457+ OF_INVALID_INIT_METHOD
458+ }
459+
446460- initWithUTF8String : (const char *)string
447461{
448- self = [self init ];
462+ self = [super init ];
449463
450464 @try {
451465 _string = [[OFString alloc ] initWithUTF8String: string];
0 commit comments