pull/1341/head
Jorge Canizales 10 years ago
parent 6465c34045
commit aa4fb1404f
  1. 37
      src/objective-c/GRPCClient/private/GRPCSecureChannel.m

@ -35,40 +35,15 @@
#import <grpc/grpc_security.h>
static const char *kCertificates =
"# Issuer: CN=GTE CyberTrust Global Root O=GTE Corporation OU=GTE CyberTrust Solutions, Inc.\n"
"# Subject: CN=GTE CyberTrust Global Root O=GTE Corporation OU=GTE CyberTrust Solutions, Inc.\n"
"# Label: \"GTE CyberTrust Global Root\"\n"
"# Serial: 421\n"
"# MD5 Fingerprint: ca:3d:d3:68:f1:03:5c:d0:32:fa:b8:2b:59:e8:5a:db\n"
"# SHA1 Fingerprint: 97:81:79:50:d8:1c:96:70:cc:34:d8:09:cf:79:44:31:36:7e:f4:74\n"
"# SHA256 Fingerprint: a5:31:25:18:8d:21:10:aa:96:4b:02:c7:b7:c6:da:32:03:17:08:94:e5:fb:71:ff:fb:66:67:d5:e6:81:0a:36\n"
"-----BEGIN CERTIFICATE-----\n"
"MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYD\n"
"VQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNv\n"
"bHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJv\n"
"b3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEzMjM1OTAwWjB1MQswCQYDVQQGEwJV\n"
"UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU\n"
"cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds\n"
"b2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrH\n"
"iM3dFw4usJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTS\n"
"r41tiGeA5u2ylc9yMcqlHHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X4\n"
"04Wqk2kmhXBIgD8SFcd5tB8FLztimQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAG3r\n"
"GwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMWM4ETCJ57NE7fQMh017l9\n"
"3PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P\n"
"lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/\n"
"-----END CERTIFICATE-----\n";
@implementation GRPCSecureChannel
- (instancetype)initWithHost:(NSString *)host {
// TODO(jcanizales): Get the certificates here.
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);
// TODO(jcanizales): Load certs only once.
NSURL *certsURL = [[NSBundle mainBundle] URLForResource:@"gRPC.bundle/roots" withExtension:@"pem"];
NSData *certsData = [NSData dataWithContentsOfURL:certsURL];
NSString *certsString = [[NSString alloc] initWithData:certsData encoding:NSUTF8StringEncoding];
grpc_credentials *credentials = grpc_ssl_credentials_create(certsString.UTF8String, NULL);
return (self = [super initWithChannel:grpc_secure_channel_create(credentials,
host.UTF8String,
NULL)]);

Loading…
Cancel
Save