mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Implement writing certificate DER data
This commit is contained in:
@@ -19,5 +19,6 @@
|
|||||||
- (nonnull instancetype) __unavailable init;
|
- (nonnull instancetype) __unavailable init;
|
||||||
|
|
||||||
- (nullable NSData *)pemData:(out NSError * __nullable * __nullable)error;
|
- (nullable NSData *)pemData:(out NSError * __nullable * __nullable)error;
|
||||||
|
- (nullable NSData *)derData:(out NSError * __nullable * __nullable)error;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -96,6 +96,19 @@
|
|||||||
return [NSData dataWithBytes:pem_buffer length:output_length];
|
return [NSData dataWithBytes:pem_buffer length:output_length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSData *)derData:(out NSError **)error {
|
||||||
|
if (self.crt->raw.p == NULL || self.crt->raw.len == 0) {
|
||||||
|
*error = [NSError errorWithDomain:OpenVPNIdentityErrorDomain code:MBEDTLS_ERR_X509_BAD_INPUT_DATA userInfo:@{
|
||||||
|
NSLocalizedDescriptionKey: @"Failed to write DER data.",
|
||||||
|
NSLocalizedFailureReasonErrorKey: @"Input invalid"
|
||||||
|
}];
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [NSData dataWithBytes:self.crt->raw.p length:self.crt->raw.len];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
mbedtls_x509_crt_free(self.crt);
|
mbedtls_x509_crt_free(self.crt);
|
||||||
free(self.crt);
|
free(self.crt);
|
||||||
|
|||||||
Reference in New Issue
Block a user