Implement -description for X509Certificate

This commit is contained in:
Florian Zeitz 2011-11-02 01:25:36 +01:00
parent 3b0fbe7868
commit 165ee6acca
2 changed files with 26 additions and 1 deletions

View file

@ -23,6 +23,7 @@
#include <openssl/x509.h>
#import <ObjFW/OFObject.h>
#import <ObjFW/OFString.h>
@class OFDictionary;
/* OIDs: */
@ -65,3 +66,6 @@
- (OFString*)X509_stringFromASN1Object: (ASN1_OBJECT*)obj;
- (OFString*)X509_stringFromASN1String: (ASN1_STRING*)str;
@end
@interface X509OID: OFString {}
@end

View file

@ -90,6 +90,18 @@
[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) {
@ -383,7 +395,7 @@
[self resizeMemory: buf
toSize: buf_len];
}
ret = [OFString stringWithUTF8String: buf];
ret = [X509OID stringWithUTF8String: buf];
[self freeMemory: buf];
return ret;
}
@ -399,3 +411,12 @@
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