Lines 371-376
void SecureContext::New(const FunctionCallbackInfo<Value>& args) {
Link Here
|
371 |
} |
371 |
} |
372 |
|
372 |
|
373 |
|
373 |
|
|
|
374 |
int string_to_tls_protocol(const char* version_str) { |
375 |
int version; |
376 |
|
377 |
if (strcmp(version_str, "TLSv1.3") == 0) { |
378 |
version = TLS1_3_VERSION; |
379 |
} else if (strcmp(version_str, "TLSv1.2") == 0) { |
380 |
version = TLS1_2_VERSION; |
381 |
} else if (strcmp(version_str, "TLSv1.1") == 0) { |
382 |
version = TLS1_1_VERSION; |
383 |
} else if (strcmp(version_str, "TLSv1") == 0) { |
384 |
version = TLS1_VERSION; |
385 |
} else { |
386 |
version = 0; |
387 |
} |
388 |
return version; |
389 |
} |
390 |
|
391 |
|
374 |
void SecureContext::Init(const FunctionCallbackInfo<Value>& args) { |
392 |
void SecureContext::Init(const FunctionCallbackInfo<Value>& args) { |
375 |
SecureContext* sc; |
393 |
SecureContext* sc; |
376 |
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); |
394 |
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); |
Lines 378-387
void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
Link Here
|
378 |
|
396 |
|
379 |
int min_version = 0; |
397 |
int min_version = 0; |
380 |
int max_version = 0; |
398 |
int max_version = 0; |
|
|
399 |
|
400 |
if (args[0]->IsString()) { |
401 |
const node::Utf8Value min(env->isolate(), args[0]); |
402 |
min_version = string_to_tls_protocol(*min); |
403 |
} |
404 |
|
405 |
if (args[1]->IsString()) { |
406 |
const node::Utf8Value max(env->isolate(), args[1]); |
407 |
max_version = string_to_tls_protocol(*max); |
408 |
} |
409 |
|
381 |
const SSL_METHOD* method = TLS_method(); |
410 |
const SSL_METHOD* method = TLS_method(); |
382 |
|
411 |
|
383 |
if (args.Length() == 1 && args[0]->IsString()) { |
412 |
if (args.Length() == 3 && args[2]->IsString()) { |
384 |
const node::Utf8Value sslmethod(env->isolate(), args[0]); |
413 |
const node::Utf8Value sslmethod(env->isolate(), args[2]); |
385 |
|
414 |
|
386 |
// Note that SSLv2 and SSLv3 are disallowed but SSLv23_method and friends |
415 |
// Note that SSLv2 and SSLv3 are disallowed but SSLv23_method and friends |
387 |
// are still accepted. They are OpenSSL's way of saying that all known |
416 |
// are still accepted. They are OpenSSL's way of saying that all known |