Index: src/X509Certificate.h ================================================================== --- src/X509Certificate.h +++ src/X509Certificate.h @@ -21,10 +21,11 @@ */ #include #import +#import @class OFDictionary; /* OIDs: */ #define OID_commonName @"2.5.4.3" #define OID_surname @"2.5.4.4" @@ -63,5 +64,8 @@ equalDomain: (OFString*)domain; - (OFDictionary*)X509_dictionaryFromX509Name: (X509_NAME*)name; - (OFString*)X509_stringFromASN1Object: (ASN1_OBJECT*)obj; - (OFString*)X509_stringFromASN1String: (ASN1_STRING*)str; @end + +@interface X509OID: OFString {} +@end Index: src/X509Certificate.m ================================================================== --- src/X509Certificate.m +++ src/X509Certificate.m @@ -87,10 +87,22 @@ if (crt != NULL) X509_free(crt); [super dealloc]; } + +- (OFString*)description +{ + OFMutableString *ret = nil;//[OFMutableString string]; + + [ret appendFormat: @"Issuer: %@\n\n", [self issuer]]; + [ret appendFormat: @"Subject: %@\n\n", [self subject]]; + [ret appendFormat: @"SANs: %@", [self subjectAlternativeName]]; + + [ret makeImmutable]; + return ret; +} - (OFDictionary*)issuer { if (issuer == nil) { X509_NAME *name = X509_get_issuer_name(crt); @@ -381,11 +393,11 @@ while ((len = OBJ_obj2txt(buf, buf_len, obj, 1)) > buf_len) { buf_len = len; [self resizeMemory: buf toSize: buf_len]; } - ret = [OFString stringWithUTF8String: buf]; + ret = [X509OID stringWithUTF8String: buf]; [self freeMemory: buf]; return ret; } - (OFString*) X509_stringFromASN1String: (ASN1_STRING*)str @@ -397,5 +409,14 @@ ret = [OFString stringWithUTF8String: buf]; OPENSSL_free(buf); return ret; } @end + +@implementation X509OID +- (OFString*)description +{ + char tmp[1024]; + OBJ_obj2txt(tmp, sizeof(tmp), OBJ_txt2obj(s->cString, 1), 0); + return [OFString stringWithUTF8String: tmp]; +} +@end