aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-12-11 07:35:28 -0800
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-12-11 07:35:28 -0800
commit0a0237183a6f8dfe4ca0cf320e0c5c4b189cbde7 (patch)
treec2525f8f46d5e6874b97b523a1a036420644c190
parenta6b2c4ce468f06094810252cfa7f136d398ddd9e (diff)
Address comments
-rw-r--r--src/ruby/ext/grpc/rb_channel_credentials.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c
index c7f4914997..5badd4bd7d 100644
--- a/src/ruby/ext/grpc/rb_channel_credentials.c
+++ b/src/ruby/ext/grpc/rb_channel_credentials.c
@@ -165,6 +165,7 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv, VALUE self)
grpc_rb_channel_credentials *wrapper = NULL;
grpc_channel_credentials *creds = NULL;
grpc_ssl_pem_key_cert_pair key_cert_pair;
+ const char *pem_root_certs_cstr = NULL;
MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
/* "03" == no mandatory arg, 3 optional */
rb_scan_args(argc, argv, "03", &pem_root_certs, &pem_private_key,
@@ -172,14 +173,15 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv, VALUE self)
TypedData_Get_Struct(self, grpc_rb_channel_credentials,
&grpc_rb_channel_credentials_data_type, wrapper);
+ if (pem_root_certs != Qnil) {
+ pem_root_certs_cstr = RSTRING_PTR(pem_root_certs);
+ }
if (pem_private_key == Qnil && pem_cert_chain == Qnil) {
- creds = grpc_ssl_credentials_create(
- pem_root_certs == Qnil ? NULL : RSTRING_PTR(pem_root_certs),
- NULL, NULL);
+ creds = grpc_ssl_credentials_create(pem_root_certs_cstr, NULL, NULL);
} else {
key_cert_pair.private_key = RSTRING_PTR(pem_private_key);
key_cert_pair.cert_chain = RSTRING_PTR(pem_cert_chain);
- creds = grpc_ssl_credentials_create(RSTRING_PTR(pem_root_certs),
+ creds = grpc_ssl_credentials_create(pem_root_certs_cstr,
&key_cert_pair, NULL);
}
if (creds == NULL) {