Wrap ca_file_name option
This commit is contained in:
parent
2c87f3593d
commit
d9c86f3e93
2
examples/WorkerThreads.js
vendored
2
examples/WorkerThreads.js
vendored
@ -17,7 +17,7 @@ if (isMainThread) {
|
|||||||
/* I guess main thread joins by default? */
|
/* I guess main thread joins by default? */
|
||||||
} else {
|
} else {
|
||||||
/* Here we are inside a worker thread */
|
/* Here we are inside a worker thread */
|
||||||
const app = uWS./*SSL*/App({
|
const app = uWS.SSLApp({
|
||||||
key_file_name: 'misc/key.pem',
|
key_file_name: 'misc/key.pem',
|
||||||
cert_file_name: 'misc/cert.pem',
|
cert_file_name: 'misc/cert.pem',
|
||||||
passphrase: '1234'
|
passphrase: '1234'
|
||||||
|
@ -256,28 +256,20 @@ template <typename APP>
|
|||||||
void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
||||||
|
|
||||||
Isolate *isolate = args.GetIsolate();
|
Isolate *isolate = args.GetIsolate();
|
||||||
|
|
||||||
Local<FunctionTemplate> appTemplate = FunctionTemplate::New(isolate);
|
Local<FunctionTemplate> appTemplate = FunctionTemplate::New(isolate);
|
||||||
|
appTemplate->SetClassName(String::NewFromUtf8(isolate, std::is_same<APP, uWS::SSLApp>::value ? "uWS.SSLApp" : "uWS.App", NewStringType::kNormal).ToLocalChecked());
|
||||||
|
|
||||||
APP *app;
|
/* Read the options object if any */
|
||||||
|
us_socket_context_options_t options = {};
|
||||||
|
if (args.Length() == 1) {
|
||||||
|
|
||||||
|
Local<Object> optionsObject = Local<Object>::Cast(args[0]);
|
||||||
|
|
||||||
/* These won't outlive the function, uSockets will have to copy strings it wants to keep! */
|
|
||||||
std::string keyFileName;
|
std::string keyFileName;
|
||||||
std::string certFileName;
|
std::string certFileName;
|
||||||
std::string passphrase;
|
std::string passphrase;
|
||||||
std::string dhParamsFileName;
|
std::string dhParamsFileName;
|
||||||
|
std::string caFileName;
|
||||||
/* Name differs based on type */
|
|
||||||
if (std::is_same<APP, uWS::SSLApp>::value) {
|
|
||||||
appTemplate->SetClassName(String::NewFromUtf8(isolate, "uWS.SSLApp", NewStringType::kNormal).ToLocalChecked());
|
|
||||||
|
|
||||||
/* We fill these below */
|
|
||||||
us_socket_context_options_t ssl_options = {};
|
|
||||||
|
|
||||||
/* Read the options object (SSL options) */
|
|
||||||
if (args.Length() == 1) {
|
|
||||||
|
|
||||||
Local<Object> optionsObject = Local<Object>::Cast(args[0]);
|
|
||||||
|
|
||||||
/* Key file name */
|
/* Key file name */
|
||||||
NativeString keyFileNameValue(isolate, optionsObject->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "key_file_name", NewStringType::kNormal).ToLocalChecked()).ToLocalChecked());
|
NativeString keyFileNameValue(isolate, optionsObject->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "key_file_name", NewStringType::kNormal).ToLocalChecked()).ToLocalChecked());
|
||||||
@ -286,7 +278,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
|||||||
}
|
}
|
||||||
if (keyFileNameValue.getString().length()) {
|
if (keyFileNameValue.getString().length()) {
|
||||||
keyFileName = keyFileNameValue.getString();
|
keyFileName = keyFileNameValue.getString();
|
||||||
ssl_options.key_file_name = keyFileName.c_str();
|
options.key_file_name = keyFileName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cert file name */
|
/* Cert file name */
|
||||||
@ -296,7 +288,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
|||||||
}
|
}
|
||||||
if (certFileNameValue.getString().length()) {
|
if (certFileNameValue.getString().length()) {
|
||||||
certFileName = certFileNameValue.getString();
|
certFileName = certFileNameValue.getString();
|
||||||
ssl_options.cert_file_name = certFileName.c_str();
|
options.cert_file_name = certFileName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Passphrase */
|
/* Passphrase */
|
||||||
@ -306,7 +298,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
|||||||
}
|
}
|
||||||
if (passphraseValue.getString().length()) {
|
if (passphraseValue.getString().length()) {
|
||||||
passphrase = passphraseValue.getString();
|
passphrase = passphraseValue.getString();
|
||||||
ssl_options.passphrase = passphrase.c_str();
|
options.passphrase = passphrase.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DH params file name */
|
/* DH params file name */
|
||||||
@ -316,19 +308,25 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
|||||||
}
|
}
|
||||||
if (dhParamsFileNameValue.getString().length()) {
|
if (dhParamsFileNameValue.getString().length()) {
|
||||||
dhParamsFileName = dhParamsFileNameValue.getString();
|
dhParamsFileName = dhParamsFileNameValue.getString();
|
||||||
ssl_options.dh_params_file_name = dhParamsFileName.c_str();
|
options.dh_params_file_name = dhParamsFileName.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CA file name */
|
||||||
|
NativeString caFileNameValue(isolate, optionsObject->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "ca_file_name", NewStringType::kNormal).ToLocalChecked()).ToLocalChecked());
|
||||||
|
if (caFileNameValue.isInvalid(args)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (caFileNameValue.getString().length()) {
|
||||||
|
caFileName = caFileNameValue.getString();
|
||||||
|
options.ca_file_name = caFileName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ssl_prefer_low_memory_usage */
|
/* ssl_prefer_low_memory_usage */
|
||||||
ssl_options.ssl_prefer_low_memory_usage = BooleanValue(isolate, optionsObject->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "ssl_prefer_low_memory_usage", NewStringType::kNormal).ToLocalChecked()).ToLocalChecked());
|
options.ssl_prefer_low_memory_usage = BooleanValue(isolate, optionsObject->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "ssl_prefer_low_memory_usage", NewStringType::kNormal).ToLocalChecked()).ToLocalChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* uSockets should really copy strings it wants to keep */
|
/* uSockets copies strings here */
|
||||||
app = new APP(ssl_options);
|
APP *app = new APP(options);
|
||||||
} else {
|
|
||||||
appTemplate->SetClassName(String::NewFromUtf8(isolate, "uWS.App", NewStringType::kNormal).ToLocalChecked());
|
|
||||||
app = new APP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Throw if we failed to construct the app */
|
/* Throw if we failed to construct the app */
|
||||||
if (app->constructorFailed()) {
|
if (app->constructorFailed()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user