diff --git a/OpenVPN Adapter/OpenVPNAdapter.mm b/OpenVPN Adapter/OpenVPNAdapter.mm index 3b5d23a..58bdd17 100644 --- a/OpenVPN Adapter/OpenVPNAdapter.mm +++ b/OpenVPN Adapter/OpenVPNAdapter.mm @@ -47,7 +47,7 @@ #pragma mark - OpenVPNClient Lifecycle -- (OpenVPNProperties *)applyConfiguration:(OpenVPNConfiguration *)configuration error:(NSError * _Nullable __autoreleasing *)error { +- (OpenVPNProperties *)applyConfiguration:(OpenVPNConfiguration *)configuration error:(NSError * __autoreleasing *)error { ClientAPI::EvalConfig eval = self.vpnClient->eval_config(configuration.config); if (eval.error) { @@ -65,7 +65,7 @@ return [[OpenVPNProperties alloc] initWithEvalConfig:eval]; } -- (BOOL)provideCredentials:(OpenVPNCredentials *)credentials error:(NSError * _Nullable __autoreleasing *)error { +- (BOOL)provideCredentials:(OpenVPNCredentials *)credentials error:(NSError * __autoreleasing *)error { ClientAPI::Status status = self.vpnClient->provide_creds(credentials.credentials); if (status.error) { diff --git a/OpenVPN Adapter/OpenVPNCertificate.h b/OpenVPN Adapter/OpenVPNCertificate.h index fb1c7f1..57d2f9c 100644 --- a/OpenVPN Adapter/OpenVPNCertificate.h +++ b/OpenVPN Adapter/OpenVPNCertificate.h @@ -8,17 +8,18 @@ #import +NS_ASSUME_NONNULL_BEGIN + @interface OpenVPNCertificate : NSObject -+ (nullable OpenVPNCertificate *)certificateWithPEM:(nonnull NSData *)pemData - error:(out NSError * _Nullable * _Nullable)error; ++ (nullable OpenVPNCertificate *)certificateWithPEM:(NSData *)pemData error:(NSError **)error; ++ (nullable OpenVPNCertificate *)certificateWithDER:(NSData *)derData error:(NSError **)error; -+ (nullable OpenVPNCertificate *)certificateWithDER:(nonnull NSData *)derData - error:(out NSError * _Nullable * _Nullable)error; +- (instancetype) init NS_UNAVAILABLE; -- (nonnull instancetype) init NS_UNAVAILABLE; - -- (nullable NSData *)pemData:(out NSError * _Nullable * _Nullable)error; -- (nullable NSData *)derData:(out NSError * _Nullable * _Nullable)error; +- (nullable NSData *)pemData:(NSError **)error; +- (nullable NSData *)derData:(NSError **)error; @end + +NS_ASSUME_NONNULL_END diff --git a/OpenVPN Adapter/OpenVPNCertificate.m b/OpenVPN Adapter/OpenVPNCertificate.m index 826792e..907843c 100644 --- a/OpenVPN Adapter/OpenVPNCertificate.m +++ b/OpenVPN Adapter/OpenVPNCertificate.m @@ -20,7 +20,7 @@ @implementation OpenVPNCertificate -+ (OpenVPNCertificate *)certificateWithPEM:(NSData *)pemData error:(out NSError **)error { ++ (OpenVPNCertificate *)certificateWithPEM:(NSData *)pemData error:(NSError * __autoreleasing *)error { OpenVPNCertificate *certificate = [OpenVPNCertificate new]; NSString *pemString = [[NSString alloc] initWithData:pemData encoding:NSUTF8StringEncoding]; @@ -37,7 +37,7 @@ return certificate; } -+ (OpenVPNCertificate *)certificateWithDER:(NSData *)derData error:(out NSError **)error { ++ (OpenVPNCertificate *)certificateWithDER:(NSData *)derData error:(NSError * __autoreleasing *)error { OpenVPNCertificate *certificate = [OpenVPNCertificate new]; int result = mbedtls_x509_crt_parse_der(certificate.crt, derData.bytes, derData.length); @@ -61,7 +61,7 @@ return self; } -- (NSData *)pemData:(out NSError **)error { +- (NSData *)pemData:(NSError * __autoreleasing *)error { NSString *header = @"-----BEGIN CERTIFICATE-----\n"; NSString *footer = @"-----END CERTIFICATE-----\n"; @@ -87,7 +87,7 @@ return pemData; } -- (NSData *)derData:(out NSError **)error { +- (NSData *)derData:(NSError * __autoreleasing *)error { if (self.crt->raw.p == NULL || self.crt->raw.len == 0) { if (error) { *error = [NSError ovpn_errorObjectForMbedTLSError:MBEDTLS_ERR_X509_BAD_INPUT_DATA diff --git a/OpenVPN Adapter/OpenVPNPacketFlowBridge.mm b/OpenVPN Adapter/OpenVPNPacketFlowBridge.mm index 4c0cc9b..5b64e26 100644 --- a/OpenVPN Adapter/OpenVPNPacketFlowBridge.mm +++ b/OpenVPN Adapter/OpenVPNPacketFlowBridge.mm @@ -41,7 +41,7 @@ static void SocketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData [bridge writePackets:@[packet] toPacketFlow:bridge.packetFlow]; } -- (BOOL)configureSocketsWithError:(NSError **)error { +- (BOOL)configureSocketsWithError:(NSError * __autoreleasing *)error { int sockets[2]; if (socketpair(PF_LOCAL, SOCK_DGRAM, IPPROTO_IP, sockets) == -1) { if (error) { @@ -90,7 +90,7 @@ static void SocketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData return YES; } -- (BOOL)configureOptionsForSocket:(CFSocketRef)socket error:(NSError **)error { +- (BOOL)configureOptionsForSocket:(CFSocketRef)socket error:(NSError * __autoreleasing *)error { CFSocketNativeHandle socketHandle = CFSocketGetNative(socket); int buf_value = 65536; diff --git a/OpenVPN Adapter/OpenVPNPrivateKey.h b/OpenVPN Adapter/OpenVPNPrivateKey.h index 61f8727..57bc4db 100644 --- a/OpenVPN Adapter/OpenVPNPrivateKey.h +++ b/OpenVPN Adapter/OpenVPNPrivateKey.h @@ -10,22 +10,26 @@ typedef NS_ENUM(NSInteger, OpenVPNKeyType); +NS_ASSUME_NONNULL_BEGIN + @interface OpenVPNPrivateKey : NSObject -+ (nullable OpenVPNPrivateKey *)keyWithPEM:(nonnull NSData *)pemData ++ (nullable OpenVPNPrivateKey *)keyWithPEM:(NSData *)pemData password:(nullable NSString *)password - error:(out NSError * _Nullable * _Nullable)error; + error:(NSError **)error; -+ (nullable OpenVPNPrivateKey *)keyWithDER:(nonnull NSData *)derData ++ (nullable OpenVPNPrivateKey *)keyWithDER:(NSData *)derData password:(nullable NSString *)password - error:(out NSError * _Nullable * _Nullable)error; + error:(NSError **)error; -- (nonnull instancetype) init NS_UNAVAILABLE; +- (instancetype) init NS_UNAVAILABLE; @property (nonatomic, readonly) NSInteger size; @property (nonatomic, readonly) OpenVPNKeyType type; -- (nullable NSData *)pemData:(out NSError * _Nullable * _Nullable)error; -- (nullable NSData *)derData:(out NSError * _Nullable * _Nullable)error; +- (nullable NSData *)pemData:(NSError **)error; +- (nullable NSData *)derData:(NSError **)error; @end + +NS_ASSUME_NONNULL_END diff --git a/OpenVPN Adapter/OpenVPNPrivateKey.m b/OpenVPN Adapter/OpenVPNPrivateKey.m index a941878..d85cd90 100644 --- a/OpenVPN Adapter/OpenVPNPrivateKey.m +++ b/OpenVPN Adapter/OpenVPNPrivateKey.m @@ -21,7 +21,7 @@ @implementation OpenVPNPrivateKey -+ (nullable OpenVPNPrivateKey *)keyWithPEM:(NSData *)pemData password:(NSString *)password error:(out NSError **)error { ++ (OpenVPNPrivateKey *)keyWithPEM:(NSData *)pemData password:(NSString *)password error:(NSError * __autoreleasing *)error { OpenVPNPrivateKey *key = [OpenVPNPrivateKey new]; NSString *pemString = [[NSString alloc] initWithData:pemData encoding:NSUTF8StringEncoding]; @@ -43,7 +43,7 @@ return key; } -+ (nullable OpenVPNPrivateKey *)keyWithDER:(NSData *)derData password:(NSString *)password error:(out NSError **)error { ++ (OpenVPNPrivateKey *)keyWithDER:(NSData *)derData password:(NSString *)password error:(NSError * __autoreleasing *)error { OpenVPNPrivateKey *key = [OpenVPNPrivateKey new]; size_t password_length = password != nil ? strlen(password.UTF8String) : 0; @@ -78,7 +78,7 @@ return (OpenVPNKeyType)mbedtls_pk_get_type(self.ctx); } -- (NSData *)pemData:(out NSError **)error { +- (NSData *)pemData:(NSError * __autoreleasing *)error { size_t buffer_length = mbedtls_pk_get_len(self.ctx) * 10; unsigned char *pem_buffer = malloc(buffer_length); @@ -99,7 +99,7 @@ return pemData; } -- (NSData *)derData:(out NSError **)error { +- (NSData *)derData:(NSError * __autoreleasing *)error { size_t buffer_length = mbedtls_pk_get_len(self.ctx) * 10; unsigned char *der_buffer = malloc(buffer_length);