mirror of https://github.com/grpc/grpc-node.git
Merge branch 'master' into node_remove_byte_streams
This commit is contained in:
commit
3279c7c7c1
|
@ -19,9 +19,6 @@
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
'-lgrpc',
|
'-lgrpc',
|
||||||
'-levent',
|
|
||||||
'-levent_pthreads',
|
|
||||||
'-levent_core',
|
|
||||||
'-lrt',
|
'-lrt',
|
||||||
'-lgpr',
|
'-lgpr',
|
||||||
'-lpthread'
|
'-lpthread'
|
||||||
|
|
|
@ -136,33 +136,29 @@ NAN_METHOD(Credentials::CreateDefault) {
|
||||||
|
|
||||||
NAN_METHOD(Credentials::CreateSsl) {
|
NAN_METHOD(Credentials::CreateSsl) {
|
||||||
NanScope();
|
NanScope();
|
||||||
char *root_certs;
|
char *root_certs = NULL;
|
||||||
char *private_key = NULL;
|
grpc_ssl_pem_key_cert_pair key_cert_pair = {NULL, NULL};
|
||||||
char *cert_chain = NULL;
|
if (Buffer::HasInstance(args[0])) {
|
||||||
int root_certs_length, private_key_length = 0, cert_chain_length = 0;
|
root_certs = Buffer::Data(args[0]);
|
||||||
if (!Buffer::HasInstance(args[0])) {
|
} else if (!(args[0]->IsNull() || args[0]->IsUndefined())) {
|
||||||
return NanThrowTypeError("createSsl's first argument must be a Buffer");
|
return NanThrowTypeError("createSsl's first argument must be a Buffer");
|
||||||
}
|
}
|
||||||
root_certs = Buffer::Data(args[0]);
|
|
||||||
root_certs_length = Buffer::Length(args[0]);
|
|
||||||
if (Buffer::HasInstance(args[1])) {
|
if (Buffer::HasInstance(args[1])) {
|
||||||
private_key = Buffer::Data(args[1]);
|
key_cert_pair.private_key = Buffer::Data(args[1]);
|
||||||
private_key_length = Buffer::Length(args[1]);
|
|
||||||
} else if (!(args[1]->IsNull() || args[1]->IsUndefined())) {
|
} else if (!(args[1]->IsNull() || args[1]->IsUndefined())) {
|
||||||
return NanThrowTypeError(
|
return NanThrowTypeError(
|
||||||
"createSSl's second argument must be a Buffer if provided");
|
"createSSl's second argument must be a Buffer if provided");
|
||||||
}
|
}
|
||||||
if (Buffer::HasInstance(args[2])) {
|
if (Buffer::HasInstance(args[2])) {
|
||||||
cert_chain = Buffer::Data(args[2]);
|
key_cert_pair.cert_chain = Buffer::Data(args[2]);
|
||||||
cert_chain_length = Buffer::Length(args[2]);
|
|
||||||
} else if (!(args[2]->IsNull() || args[2]->IsUndefined())) {
|
} else if (!(args[2]->IsNull() || args[2]->IsUndefined())) {
|
||||||
return NanThrowTypeError(
|
return NanThrowTypeError(
|
||||||
"createSSl's third argument must be a Buffer if provided");
|
"createSSl's third argument must be a Buffer if provided");
|
||||||
}
|
}
|
||||||
|
|
||||||
NanReturnValue(WrapStruct(grpc_ssl_credentials_create(
|
NanReturnValue(WrapStruct(grpc_ssl_credentials_create(
|
||||||
reinterpret_cast<unsigned char *>(root_certs), root_certs_length,
|
root_certs,
|
||||||
reinterpret_cast<unsigned char *>(private_key), private_key_length,
|
key_cert_pair.private_key == NULL ? NULL : &key_cert_pair)));
|
||||||
reinterpret_cast<unsigned char *>(cert_chain), cert_chain_length)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(Credentials::CreateComposite) {
|
NAN_METHOD(Credentials::CreateComposite) {
|
||||||
|
|
|
@ -123,14 +123,12 @@ NAN_METHOD(ServerCredentials::New) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(ServerCredentials::CreateSsl) {
|
NAN_METHOD(ServerCredentials::CreateSsl) {
|
||||||
|
// TODO: have the node API support multiple key/cert pairs.
|
||||||
NanScope();
|
NanScope();
|
||||||
char *root_certs = NULL;
|
char *root_certs = NULL;
|
||||||
char *private_key;
|
grpc_ssl_pem_key_cert_pair key_cert_pair;
|
||||||
char *cert_chain;
|
|
||||||
int root_certs_length = 0, private_key_length, cert_chain_length;
|
|
||||||
if (Buffer::HasInstance(args[0])) {
|
if (Buffer::HasInstance(args[0])) {
|
||||||
root_certs = Buffer::Data(args[0]);
|
root_certs = Buffer::Data(args[0]);
|
||||||
root_certs_length = Buffer::Length(args[0]);
|
|
||||||
} else if (!(args[0]->IsNull() || args[0]->IsUndefined())) {
|
} else if (!(args[0]->IsNull() || args[0]->IsUndefined())) {
|
||||||
return NanThrowTypeError(
|
return NanThrowTypeError(
|
||||||
"createSSl's first argument must be a Buffer if provided");
|
"createSSl's first argument must be a Buffer if provided");
|
||||||
|
@ -138,17 +136,13 @@ NAN_METHOD(ServerCredentials::CreateSsl) {
|
||||||
if (!Buffer::HasInstance(args[1])) {
|
if (!Buffer::HasInstance(args[1])) {
|
||||||
return NanThrowTypeError("createSsl's second argument must be a Buffer");
|
return NanThrowTypeError("createSsl's second argument must be a Buffer");
|
||||||
}
|
}
|
||||||
private_key = Buffer::Data(args[1]);
|
key_cert_pair.private_key = Buffer::Data(args[1]);
|
||||||
private_key_length = Buffer::Length(args[1]);
|
|
||||||
if (!Buffer::HasInstance(args[2])) {
|
if (!Buffer::HasInstance(args[2])) {
|
||||||
return NanThrowTypeError("createSsl's third argument must be a Buffer");
|
return NanThrowTypeError("createSsl's third argument must be a Buffer");
|
||||||
}
|
}
|
||||||
cert_chain = Buffer::Data(args[2]);
|
key_cert_pair.cert_chain = Buffer::Data(args[2]);
|
||||||
cert_chain_length = Buffer::Length(args[2]);
|
NanReturnValue(WrapStruct(
|
||||||
NanReturnValue(WrapStruct(grpc_ssl_server_credentials_create(
|
grpc_ssl_server_credentials_create(root_certs, &key_cert_pair, 1)));
|
||||||
reinterpret_cast<unsigned char *>(root_certs), root_certs_length,
|
|
||||||
reinterpret_cast<unsigned char *>(private_key), private_key_length,
|
|
||||||
reinterpret_cast<unsigned char *>(cert_chain), cert_chain_length)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(ServerCredentials::CreateFake) {
|
NAN_METHOD(ServerCredentials::CreateFake) {
|
||||||
|
|
Loading…
Reference in New Issue