From 9cc94566978b2c23bc19e4863d4aa90026f84f89 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 10 Apr 2019 14:42:51 -0700 Subject: [PATCH] Fix certificate search on mac --- .../GRPCClient/private/GRPCSecureChannelFactory.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m index b1a6797b9e3..ca427d7a99b 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m @@ -54,10 +54,12 @@ error:(NSError **)errorPtr { static dispatch_once_t loading; dispatch_once(&loading, ^{ - NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem + NSString *rootsPEM = @"roots"; + NSString *resourceBundlePath = @"gRPCCertificates.bundle"; // .pem // Do not use NSBundle.mainBundle, as it's nil for tests of library projects. NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"]; + NSBundle *resourceBundle = [NSBundle bundleWithURL:[[bundle resourceURL] URLByAppendingPathComponent:resourceBundlePath]]; + NSString *path = [resourceBundle pathForResource:rootsPEM ofType:@"pem"]; setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, [path cStringUsingEncoding:NSUTF8StringEncoding], 1); });