49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
+
-
+
|
OFDataArray *data = [fd readDataArrayTillEndOfStream];
[fd close];
const unsigned char *dataCArray = [data cArray];
crt = d2i_X509(NULL, &dataCArray, [data count]);
[pool release];
if (crt == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: isa];
exceptionWithClass: [self class]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithX509Struct: (X509*)cert
{
self = [self init];
@try {
crt = X509_dup(cert);
if (crt == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: isa];
exceptionWithClass: [self class]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
-
+
+
|
- (OFString*)X509_stringFromASN1String: (ASN1_STRING*)str
{
OFString *ret;
char *buffer;
if (ASN1_STRING_to_UTF8((unsigned char**)&buffer, str) < 0)
@throw [OFInvalidEncodingException exceptionWithClass: isa];
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
@try {
ret = [OFString stringWithUTF8String: buffer];
} @finally {
OPENSSL_free(buffer);
}
|