|
|
@ -845,7 +845,7 @@ int SSLWrap<Base>::NewSessionCallback(SSL* s, SSL_SESSION* sess) { |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
Base* w = static_cast<Base*>(SSL_get_app_data(s)); |
|
|
|
Environment* env = w->env(); |
|
|
|
Environment* env = w->ssl_env(); |
|
|
|
|
|
|
|
if (!w->session_callbacks_) |
|
|
|
return 0; |
|
|
@ -866,11 +866,7 @@ int SSLWrap<Base>::NewSessionCallback(SSL* s, SSL_SESSION* sess) { |
|
|
|
reinterpret_cast<char*>(sess->session_id), |
|
|
|
sess->session_id_length); |
|
|
|
Local<Value> argv[] = { session, buff }; |
|
|
|
MakeCallback(env, |
|
|
|
w->weak_object(node_isolate), |
|
|
|
env->onnewsession_string(), |
|
|
|
ARRAY_SIZE(argv), |
|
|
|
argv); |
|
|
|
w->MakeCallback(env->onnewsession_string(), ARRAY_SIZE(argv), argv); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
@ -882,7 +878,7 @@ void SSLWrap<Base>::OnClientHello(void* arg, |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
Base* w = static_cast<Base*>(arg); |
|
|
|
Environment* env = w->env(); |
|
|
|
Environment* env = w->ssl_env(); |
|
|
|
|
|
|
|
Local<Object> hello_obj = Object::New(); |
|
|
|
Local<Object> buff = Buffer::New( |
|
|
@ -901,11 +897,7 @@ void SSLWrap<Base>::OnClientHello(void* arg, |
|
|
|
hello_obj->Set(env->tls_ticket_string(), Boolean::New(hello.has_ticket())); |
|
|
|
|
|
|
|
Local<Value> argv[] = { hello_obj }; |
|
|
|
MakeCallback(env, |
|
|
|
w->weak_object(node_isolate), |
|
|
|
env->onclienthello_string(), |
|
|
|
ARRAY_SIZE(argv), |
|
|
|
argv); |
|
|
|
w->MakeCallback(env->onclienthello_string(), ARRAY_SIZE(argv), argv); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -916,7 +908,7 @@ void SSLWrap<Base>::GetPeerCertificate( |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
Base* w = Unwrap<Base>(args.This()); |
|
|
|
Environment* env = w->env(); |
|
|
|
Environment* env = w->ssl_env(); |
|
|
|
|
|
|
|
Local<Object> info = Object::New(); |
|
|
|
X509* peer_cert = SSL_get_peer_certificate(w->ssl_); |
|
|
@ -1109,7 +1101,7 @@ void SSLWrap<Base>::LoadSession(const FunctionCallbackInfo<Value>& args) { |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
Base* w = Unwrap<Base>(args.This()); |
|
|
|
Environment* env = w->env(); |
|
|
|
Environment* env = w->ssl_env(); |
|
|
|
|
|
|
|
if (args.Length() >= 1 && Buffer::HasInstance(args[0])) { |
|
|
|
ssize_t slen = Buffer::Length(args[0]); |
|
|
@ -1258,7 +1250,7 @@ void SSLWrap<Base>::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) { |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
Base* w = Unwrap<Base>(args.This()); |
|
|
|
Environment* env = w->env(); |
|
|
|
Environment* env = w->ssl_env(); |
|
|
|
|
|
|
|
OPENSSL_CONST SSL_CIPHER* c = SSL_get_current_cipher(w->ssl_); |
|
|
|
if (c == NULL) |
|
|
@ -1432,8 +1424,7 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) { |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
Local<Value> exception = |
|
|
|
Exception::Error(OneByteString(node_isolate, ssl_error_buf)); |
|
|
|
weak_object(node_isolate)->Set( |
|
|
|
FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception); |
|
|
|
object()->Set(FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception); |
|
|
|
|
|
|
|
DEBUG_PRINT("[%p] BIO: %s failed: (%d) %s\n", |
|
|
|
ssl_, |
|
|
@ -1476,8 +1467,7 @@ int Connection::HandleSSLError(const char* func, |
|
|
|
} else if (err == SSL_ERROR_ZERO_RETURN) { |
|
|
|
Local<Value> exception = |
|
|
|
Exception::Error(FIXED_ONE_BYTE_STRING(node_isolate, "ZERO_RETURN")); |
|
|
|
weak_object(node_isolate)->Set( |
|
|
|
FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception); |
|
|
|
object()->Set(FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception); |
|
|
|
return rv; |
|
|
|
|
|
|
|
} else if (err == SSL_ERROR_SYSCALL && ss == kIgnoreSyscall) { |
|
|
@ -1501,8 +1491,7 @@ int Connection::HandleSSLError(const char* func, |
|
|
|
BIO_get_mem_ptr(bio, &mem); |
|
|
|
Local<Value> exception = |
|
|
|
Exception::Error(OneByteString(node_isolate, mem->data, mem->length)); |
|
|
|
weak_object(node_isolate)->Set( |
|
|
|
FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception); |
|
|
|
object()->Set(FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception); |
|
|
|
BIO_free_all(bio); |
|
|
|
} |
|
|
|
|
|
|
@ -1519,7 +1508,7 @@ void Connection::ClearError() { |
|
|
|
|
|
|
|
// We should clear the error in JS-land
|
|
|
|
Local<String> error_key = FIXED_ONE_BYTE_STRING(node_isolate, "error"); |
|
|
|
Local<Value> error = weak_object(node_isolate)->Get(error_key); |
|
|
|
Local<Value> error = object()->Get(error_key); |
|
|
|
assert(error->BooleanValue() == false); |
|
|
|
#endif // NDEBUG
|
|
|
|
} |
|
|
@ -1533,13 +1522,13 @@ void Connection::SetShutdownFlags() { |
|
|
|
if (flags & SSL_SENT_SHUTDOWN) { |
|
|
|
Local<String> sent_shutdown_key = |
|
|
|
FIXED_ONE_BYTE_STRING(node_isolate, "sentShutdown"); |
|
|
|
weak_object(node_isolate)->Set(sent_shutdown_key, True(node_isolate)); |
|
|
|
object()->Set(sent_shutdown_key, True(node_isolate)); |
|
|
|
} |
|
|
|
|
|
|
|
if (flags & SSL_RECEIVED_SHUTDOWN) { |
|
|
|
Local<String> received_shutdown_key = |
|
|
|
FIXED_ONE_BYTE_STRING(node_isolate, "receivedShutdown"); |
|
|
|
weak_object(node_isolate)->Set(received_shutdown_key, True(node_isolate)); |
|
|
|
object()->Set(received_shutdown_key, True(node_isolate)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1644,10 +1633,8 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { |
|
|
|
if (!conn->sniObject_.IsEmpty()) { |
|
|
|
conn->sniContext_.Dispose(); |
|
|
|
|
|
|
|
Local<Object> sni_object = |
|
|
|
PersistentToLocal(node_isolate, conn->sniObject_); |
|
|
|
Local<Value> arg = PersistentToLocal(node_isolate, conn->servername_); |
|
|
|
Local<Value> ret = MakeCallback(env, sni_object, "onselect", 1, &arg); |
|
|
|
Local<Value> ret = conn->MakeCallback(env->onselect_string(), 1, &arg); |
|
|
|
|
|
|
|
// If ret is SecureContext
|
|
|
|
Local<FunctionTemplate> secure_context_constructor_template = |
|
|
@ -1766,15 +1753,11 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) { |
|
|
|
HandleScope handle_scope(env->isolate()); |
|
|
|
|
|
|
|
if (where & SSL_CB_HANDSHAKE_START) { |
|
|
|
MakeCallback(env, |
|
|
|
conn->weak_object(node_isolate), |
|
|
|
env->onhandshakestart_string()); |
|
|
|
conn->MakeCallback(env->onhandshakestart_string(), 0, NULL); |
|
|
|
} |
|
|
|
|
|
|
|
if (where & SSL_CB_HANDSHAKE_DONE) { |
|
|
|
MakeCallback(env, |
|
|
|
conn->weak_object(node_isolate), |
|
|
|
env->onhandshakedone_string()); |
|
|
|
conn->MakeCallback(env->onhandshakedone_string(), 0, NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -2088,7 +2071,8 @@ void CipherBase::Initialize(Environment* env, Handle<Object> target) { |
|
|
|
void CipherBase::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
assert(args.IsConstructCall() == true); |
|
|
|
CipherKind kind = args[0]->IsTrue() ? kCipher : kDecipher; |
|
|
|
new CipherBase(args.GetIsolate(), args.This(), kind); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
new CipherBase(env, args.This(), kind); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2329,7 +2313,8 @@ void Hmac::Initialize(Environment* env, v8::Handle<v8::Object> target) { |
|
|
|
|
|
|
|
|
|
|
|
void Hmac::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
new Hmac(args.GetIsolate(), args.This()); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
new Hmac(env, args.This()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2466,7 +2451,8 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
|
|
|
|
const String::Utf8Value hash_type(args[0]); |
|
|
|
|
|
|
|
Hash* hash = new Hash(args.GetIsolate(), args.This()); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
Hash* hash = new Hash(env, args.This()); |
|
|
|
if (!hash->HashInit(*hash_type)) { |
|
|
|
return ThrowError("Digest method not supported"); |
|
|
|
} |
|
|
@ -2565,7 +2551,8 @@ void Sign::Initialize(Environment* env, v8::Handle<v8::Object> target) { |
|
|
|
|
|
|
|
|
|
|
|
void Sign::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
new Sign(args.GetIsolate(), args.This()); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
new Sign(env, args.This()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2746,7 +2733,8 @@ void Verify::Initialize(Environment* env, v8::Handle<v8::Object> target) { |
|
|
|
|
|
|
|
|
|
|
|
void Verify::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
new Verify(args.GetIsolate(), args.This()); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
new Verify(env, args.This()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3006,8 +2994,8 @@ void DiffieHellman::DiffieHellmanGroup( |
|
|
|
const FunctionCallbackInfo<Value>& args) { |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
DiffieHellman* diffieHellman = |
|
|
|
new DiffieHellman(args.GetIsolate(), args.This()); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
DiffieHellman* diffieHellman = new DiffieHellman(env, args.This()); |
|
|
|
|
|
|
|
if (args.Length() != 1 || !args[0]->IsString()) { |
|
|
|
return ThrowError("No group name given"); |
|
|
@ -3034,8 +3022,9 @@ void DiffieHellman::DiffieHellmanGroup( |
|
|
|
void DiffieHellman::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
HandleScope scope(node_isolate); |
|
|
|
|
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
DiffieHellman* diffieHellman = |
|
|
|
new DiffieHellman(args.GetIsolate(), args.This()); |
|
|
|
new DiffieHellman(env, args.This()); |
|
|
|
bool initialized = false; |
|
|
|
|
|
|
|
if (args.Length() > 0) { |
|
|
@ -3353,7 +3342,7 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) { |
|
|
|
req->obj.Dispose(); |
|
|
|
Local<Value> argv[2]; |
|
|
|
EIO_PBKDF2After(req, argv); |
|
|
|
MakeCallback(env, obj, "ondone", ARRAY_SIZE(argv), argv); |
|
|
|
MakeCallback(env, obj, env->ondone_string(), ARRAY_SIZE(argv), argv); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3532,7 +3521,7 @@ void RandomBytesAfter(uv_work_t* work_req, int status) { |
|
|
|
Local<Value> argv[2]; |
|
|
|
RandomBytesCheck(req, argv); |
|
|
|
Local<Object> obj = PersistentToLocal(node_isolate, req->obj_); |
|
|
|
MakeCallback(env, obj, "ondone", ARRAY_SIZE(argv), argv); |
|
|
|
MakeCallback(env, obj, env->ondone_string(), ARRAY_SIZE(argv), argv); |
|
|
|
delete req; |
|
|
|
} |
|
|
|
|
|
|
@ -3664,7 +3653,8 @@ void Certificate::Initialize(Handle<Object> target) { |
|
|
|
|
|
|
|
|
|
|
|
void Certificate::New(const FunctionCallbackInfo<Value>& args) { |
|
|
|
new Certificate(args.GetIsolate(), args.This()); |
|
|
|
Environment* env = Environment::GetCurrent(args.GetIsolate()); |
|
|
|
new Certificate(env, args.This()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|