diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 6953efd03ff..85b95dee914 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -137,10 +137,7 @@ static NSMutableDictionary *kHostCache; completionQueue:queue]; } -- (NSData *)nullTerminatedDataWithString:(NSString *_Nullable)string { - if (string == nil) { - return nil; - } +- (NSData *)nullTerminatedDataWithString:(NSString *)string { // dataUsingEncoding: does not return a null-terminated string. NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSMutableData *nullTerminated = [NSMutableData dataWithData:data]; @@ -196,6 +193,7 @@ static NSMutableDictionary *kHostCache; if (pemPrivateKey == nil && pemCertChain == nil) { creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL, NULL); } else { + assert(pemPrivateKey != nil && pemCertChain != nil); grpc_ssl_pem_key_cert_pair key_cert_pair; NSData *privateKeyASCII = [self nullTerminatedDataWithString:pemPrivateKey]; NSData *certChainASCII = [self nullTerminatedDataWithString:pemCertChain];