From 6465c3404556fe38a6516b068b2b26f049a1d14b Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Mon, 23 Mar 2015 15:37:35 -0700 Subject: [PATCH] Loads certificates from file. SSL works ^^ --- src/objective-c/GRPCClient/private/GRPCSecureChannel.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m index 5ed788347c7..f5b132e99ab 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m @@ -64,7 +64,11 @@ static const char *kCertificates = - (instancetype)initWithHost:(NSString *)host { // TODO(jcanizales): Get the certificates here. - grpc_credentials *credentials = grpc_ssl_credentials_create(kCertificates, NULL); + NSURL *url = [[NSBundle mainBundle] URLForResource:@"gRPC.bundle/roots" withExtension:@"pem"]; + NSData *fontData = [NSData dataWithContentsOfURL:url]; + NSString *str = [[NSString alloc] initWithData:fontData encoding:NSUTF8StringEncoding]; + NSLog(@"Certs:\n%@", str); + grpc_credentials *credentials = grpc_ssl_credentials_create(str.UTF8String, NULL); return (self = [super initWithChannel:grpc_secure_channel_create(credentials, host.UTF8String, NULL)]);