|
@ -233,7 +233,7 @@ Handle<Value> SecureContext::Init(const Arguments& args) { |
|
|
SSL_CTX_sess_set_new_cb(sc->ctx_, NewSessionCallback); |
|
|
SSL_CTX_sess_set_new_cb(sc->ctx_, NewSessionCallback); |
|
|
|
|
|
|
|
|
sc->ca_store_ = NULL; |
|
|
sc->ca_store_ = NULL; |
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -349,7 +349,7 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BIO *bio = LoadBIO(args[0]); |
|
|
BIO *bio = LoadBIO(args[0]); |
|
|
if (!bio) return False(node_isolate); |
|
|
if (!bio) return False(); |
|
|
|
|
|
|
|
|
String::Utf8Value passphrase(args[1]); |
|
|
String::Utf8Value passphrase(args[1]); |
|
|
|
|
|
|
|
@ -370,7 +370,7 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) { |
|
|
EVP_PKEY_free(key); |
|
|
EVP_PKEY_free(key); |
|
|
BIO_free(bio); |
|
|
BIO_free(bio); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -451,7 +451,7 @@ Handle<Value> SecureContext::SetCert(const Arguments& args) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BIO* bio = LoadBIO(args[0]); |
|
|
BIO* bio = LoadBIO(args[0]); |
|
|
if (!bio) return False(node_isolate); |
|
|
if (!bio) return False(); |
|
|
|
|
|
|
|
|
int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio); |
|
|
int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio); |
|
|
|
|
|
|
|
@ -466,7 +466,7 @@ Handle<Value> SecureContext::SetCert(const Arguments& args) { |
|
|
return ThrowCryptoError(err); |
|
|
return ThrowCryptoError(err); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -486,7 +486,7 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
X509* x509 = LoadX509(args[0]); |
|
|
X509* x509 = LoadX509(args[0]); |
|
|
if (!x509) return False(node_isolate); |
|
|
if (!x509) return False(); |
|
|
|
|
|
|
|
|
X509_STORE_add_cert(sc->ca_store_, x509); |
|
|
X509_STORE_add_cert(sc->ca_store_, x509); |
|
|
SSL_CTX_add_client_CA(sc->ctx_, x509); |
|
|
SSL_CTX_add_client_CA(sc->ctx_, x509); |
|
@ -497,7 +497,7 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) { |
|
|
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); |
|
|
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -511,13 +511,13 @@ Handle<Value> SecureContext::AddCRL(const Arguments& args) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BIO *bio = LoadBIO(args[0]); |
|
|
BIO *bio = LoadBIO(args[0]); |
|
|
if (!bio) return False(node_isolate); |
|
|
if (!bio) return False(); |
|
|
|
|
|
|
|
|
X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); |
|
|
X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); |
|
|
|
|
|
|
|
|
if (x509 == NULL) { |
|
|
if (x509 == NULL) { |
|
|
BIO_free(bio); |
|
|
BIO_free(bio); |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
X509_STORE_add_crl(sc->ca_store_, x509); |
|
|
X509_STORE_add_crl(sc->ca_store_, x509); |
|
@ -528,7 +528,7 @@ Handle<Value> SecureContext::AddCRL(const Arguments& args) { |
|
|
BIO_free(bio); |
|
|
BIO_free(bio); |
|
|
X509_CRL_free(x509); |
|
|
X509_CRL_free(x509); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -548,14 +548,14 @@ Handle<Value> SecureContext::AddRootCerts(const Arguments& args) { |
|
|
|
|
|
|
|
|
if (!BIO_write(bp, root_certs[i], strlen(root_certs[i]))) { |
|
|
if (!BIO_write(bp, root_certs[i], strlen(root_certs[i]))) { |
|
|
BIO_free(bp); |
|
|
BIO_free(bp); |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
X509 *x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL); |
|
|
X509 *x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL); |
|
|
|
|
|
|
|
|
if (x509 == NULL) { |
|
|
if (x509 == NULL) { |
|
|
BIO_free(bp); |
|
|
BIO_free(bp); |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
X509_STORE_add_cert(root_cert_store, x509); |
|
|
X509_STORE_add_cert(root_cert_store, x509); |
|
@ -568,7 +568,7 @@ Handle<Value> SecureContext::AddRootCerts(const Arguments& args) { |
|
|
sc->ca_store_ = root_cert_store; |
|
|
sc->ca_store_ = root_cert_store; |
|
|
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); |
|
|
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -584,7 +584,7 @@ Handle<Value> SecureContext::SetCiphers(const Arguments& args) { |
|
|
String::Utf8Value ciphers(args[0]); |
|
|
String::Utf8Value ciphers(args[0]); |
|
|
SSL_CTX_set_cipher_list(sc->ctx_, *ciphers); |
|
|
SSL_CTX_set_cipher_list(sc->ctx_, *ciphers); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Handle<Value> SecureContext::SetOptions(const Arguments& args) { |
|
|
Handle<Value> SecureContext::SetOptions(const Arguments& args) { |
|
@ -598,7 +598,7 @@ Handle<Value> SecureContext::SetOptions(const Arguments& args) { |
|
|
|
|
|
|
|
|
SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue()); |
|
|
SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue()); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) { |
|
|
Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) { |
|
@ -630,14 +630,14 @@ Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) { |
|
|
return ThrowException(Exception::TypeError(message)); |
|
|
return ThrowException(Exception::TypeError(message)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Handle<Value> SecureContext::Close(const Arguments& args) { |
|
|
Handle<Value> SecureContext::Close(const Arguments& args) { |
|
|
HandleScope scope; |
|
|
HandleScope scope; |
|
|
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); |
|
|
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); |
|
|
sc->FreeCTXMem(); |
|
|
sc->FreeCTXMem(); |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Takes .pfx or .p12 and password in string or buffer format
|
|
|
//Takes .pfx or .p12 and password in string or buffer format
|
|
@ -714,7 +714,7 @@ Handle<Value> SecureContext::LoadPKCS12(const Arguments& args) { |
|
|
return ThrowException(Exception::Error(String::New(str))); |
|
|
return ThrowException(Exception::Error(String::New(str))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -960,11 +960,11 @@ void Connection::SetShutdownFlags() { |
|
|
int flags = SSL_get_shutdown(ssl_); |
|
|
int flags = SSL_get_shutdown(ssl_); |
|
|
|
|
|
|
|
|
if (flags & SSL_SENT_SHUTDOWN) { |
|
|
if (flags & SSL_SENT_SHUTDOWN) { |
|
|
handle_->Set(String::New("sentShutdown"), True(node_isolate)); |
|
|
handle_->Set(String::New("sentShutdown"), True()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (flags & SSL_RECEIVED_SHUTDOWN) { |
|
|
if (flags & SSL_RECEIVED_SHUTDOWN) { |
|
|
handle_->Set(String::New("receivedShutdown"), True(node_isolate)); |
|
|
handle_->Set(String::New("receivedShutdown"), True()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1094,7 +1094,7 @@ int Connection::SelectNextProtoCallback_(SSL *s, |
|
|
*outlen = 8; |
|
|
*outlen = 8; |
|
|
|
|
|
|
|
|
// set status unsupported
|
|
|
// set status unsupported
|
|
|
p->selectedNPNProto_ = Persistent<Value>::New(False(node_isolate)); |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(False()); |
|
|
|
|
|
|
|
|
return SSL_TLSEXT_ERR_OK; |
|
|
return SSL_TLSEXT_ERR_OK; |
|
|
} |
|
|
} |
|
@ -1107,7 +1107,7 @@ int Connection::SelectNextProtoCallback_(SSL *s, |
|
|
|
|
|
|
|
|
switch (status) { |
|
|
switch (status) { |
|
|
case OPENSSL_NPN_UNSUPPORTED: |
|
|
case OPENSSL_NPN_UNSUPPORTED: |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(Null(node_isolate)); |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(Null()); |
|
|
break; |
|
|
break; |
|
|
case OPENSSL_NPN_NEGOTIATED: |
|
|
case OPENSSL_NPN_NEGOTIATED: |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(String::New( |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(String::New( |
|
@ -1115,7 +1115,7 @@ int Connection::SelectNextProtoCallback_(SSL *s, |
|
|
)); |
|
|
)); |
|
|
break; |
|
|
break; |
|
|
case OPENSSL_NPN_NO_OVERLAP: |
|
|
case OPENSSL_NPN_NO_OVERLAP: |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(False(node_isolate)); |
|
|
p->selectedNPNProto_ = Persistent<Value>::New(False()); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
break; |
|
|
break; |
|
@ -1149,8 +1149,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { |
|
|
Local<Value> argv[1] = {*p->servername_}; |
|
|
Local<Value> argv[1] = {*p->servername_}; |
|
|
|
|
|
|
|
|
// Call it
|
|
|
// Call it
|
|
|
Local<Value> ret = Local<Value>::New(node_isolate, |
|
|
Local<Value> ret = Local<Value>::New(MakeCallback(p->sniObject_, |
|
|
MakeCallback(p->sniObject_, |
|
|
|
|
|
"onselect", |
|
|
"onselect", |
|
|
ARRAY_SIZE(argv), |
|
|
ARRAY_SIZE(argv), |
|
|
argv)); |
|
|
argv)); |
|
@ -1321,7 +1320,7 @@ Handle<Value> Connection::EncIn(const Arguments& args) { |
|
|
ss->SetShutdownFlags(); |
|
|
ss->SetShutdownFlags(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(bytes_written, node_isolate)); |
|
|
return scope.Close(Integer::New(bytes_written)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1366,14 +1365,14 @@ Handle<Value> Connection::ClearOut(const Arguments& args) { |
|
|
ss->HandleSSLError("SSL_connect:ClearOut", rv, kZeroIsAnError); |
|
|
ss->HandleSSLError("SSL_connect:ClearOut", rv, kZeroIsAnError); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (rv < 0) return scope.Close(Integer::New(rv, node_isolate)); |
|
|
if (rv < 0) return scope.Close(Integer::New(rv)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int bytes_read = SSL_read(ss->ssl_, buffer_data + off, len); |
|
|
int bytes_read = SSL_read(ss->ssl_, buffer_data + off, len); |
|
|
ss->HandleSSLError("SSL_read:ClearOut", bytes_read, kZeroIsNotAnError); |
|
|
ss->HandleSSLError("SSL_read:ClearOut", bytes_read, kZeroIsNotAnError); |
|
|
ss->SetShutdownFlags(); |
|
|
ss->SetShutdownFlags(); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(bytes_read, node_isolate)); |
|
|
return scope.Close(Integer::New(bytes_read)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1383,7 +1382,7 @@ Handle<Value> Connection::ClearPending(const Arguments& args) { |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
int bytes_pending = BIO_pending(ss->bio_read_); |
|
|
int bytes_pending = BIO_pending(ss->bio_read_); |
|
|
return scope.Close(Integer::New(bytes_pending, node_isolate)); |
|
|
return scope.Close(Integer::New(bytes_pending)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1393,7 +1392,7 @@ Handle<Value> Connection::EncPending(const Arguments& args) { |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
int bytes_pending = BIO_pending(ss->bio_write_); |
|
|
int bytes_pending = BIO_pending(ss->bio_write_); |
|
|
return scope.Close(Integer::New(bytes_pending, node_isolate)); |
|
|
return scope.Close(Integer::New(bytes_pending)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1432,7 +1431,7 @@ Handle<Value> Connection::EncOut(const Arguments& args) { |
|
|
ss->HandleBIOError(ss->bio_write_, "BIO_read:EncOut", bytes_read); |
|
|
ss->HandleBIOError(ss->bio_write_, "BIO_read:EncOut", bytes_read); |
|
|
ss->SetShutdownFlags(); |
|
|
ss->SetShutdownFlags(); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(bytes_read, node_isolate)); |
|
|
return scope.Close(Integer::New(bytes_read)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1476,7 +1475,7 @@ Handle<Value> Connection::ClearIn(const Arguments& args) { |
|
|
ss->HandleSSLError("SSL_connect:ClearIn", rv, kZeroIsAnError); |
|
|
ss->HandleSSLError("SSL_connect:ClearIn", rv, kZeroIsAnError); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (rv < 0) return scope.Close(Integer::New(rv, node_isolate)); |
|
|
if (rv < 0) return scope.Close(Integer::New(rv)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int bytes_written = SSL_write(ss->ssl_, buffer_data + off, len); |
|
|
int bytes_written = SSL_write(ss->ssl_, buffer_data + off, len); |
|
@ -1484,7 +1483,7 @@ Handle<Value> Connection::ClearIn(const Arguments& args) { |
|
|
ss->HandleSSLError("SSL_write:ClearIn", bytes_written, kZeroIsAnError); |
|
|
ss->HandleSSLError("SSL_write:ClearIn", bytes_written, kZeroIsAnError); |
|
|
ss->SetShutdownFlags(); |
|
|
ss->SetShutdownFlags(); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(bytes_written, node_isolate)); |
|
|
return scope.Close(Integer::New(bytes_written)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1493,7 +1492,7 @@ Handle<Value> Connection::GetPeerCertificate(const Arguments& args) { |
|
|
|
|
|
|
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL) return Undefined(node_isolate); |
|
|
if (ss->ssl_ == NULL) return Undefined(); |
|
|
Local<Object> info = Object::New(); |
|
|
Local<Object> info = Object::New(); |
|
|
X509* peer_cert = SSL_get_peer_certificate(ss->ssl_); |
|
|
X509* peer_cert = SSL_get_peer_certificate(ss->ssl_); |
|
|
if (peer_cert != NULL) { |
|
|
if (peer_cert != NULL) { |
|
@ -1595,7 +1594,7 @@ Handle<Value> Connection::GetPeerCertificate(const Arguments& args) { |
|
|
for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { |
|
|
for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1); |
|
|
OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1); |
|
|
ext_key_usage->Set(Integer::New(i, node_isolate), String::New(buf)); |
|
|
ext_key_usage->Set(Integer::New(i), String::New(buf)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free); |
|
|
sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free); |
|
@ -1612,10 +1611,10 @@ Handle<Value> Connection::GetSession(const Arguments& args) { |
|
|
|
|
|
|
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL) return Undefined(node_isolate); |
|
|
if (ss->ssl_ == NULL) return Undefined(); |
|
|
|
|
|
|
|
|
SSL_SESSION* sess = SSL_get_session(ss->ssl_); |
|
|
SSL_SESSION* sess = SSL_get_session(ss->ssl_); |
|
|
if (!sess) return Undefined(node_isolate); |
|
|
if (!sess) return Undefined(); |
|
|
|
|
|
|
|
|
int slen = i2d_SSL_SESSION(sess, NULL); |
|
|
int slen = i2d_SSL_SESSION(sess, NULL); |
|
|
assert(slen > 0); |
|
|
assert(slen > 0); |
|
@ -1629,7 +1628,7 @@ Handle<Value> Connection::GetSession(const Arguments& args) { |
|
|
return scope.Close(s); |
|
|
return scope.Close(s); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return Null(node_isolate); |
|
|
return Null(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Handle<Value> Connection::SetSession(const Arguments& args) { |
|
|
Handle<Value> Connection::SetSession(const Arguments& args) { |
|
@ -1662,7 +1661,7 @@ Handle<Value> Connection::SetSession(const Arguments& args) { |
|
|
delete [] sbuf; |
|
|
delete [] sbuf; |
|
|
|
|
|
|
|
|
if (!sess) |
|
|
if (!sess) |
|
|
return Undefined(node_isolate); |
|
|
return Undefined(); |
|
|
|
|
|
|
|
|
int r = SSL_set_session(ss->ssl_, sess); |
|
|
int r = SSL_set_session(ss->ssl_, sess); |
|
|
SSL_SESSION_free(sess); |
|
|
SSL_SESSION_free(sess); |
|
@ -1672,7 +1671,7 @@ Handle<Value> Connection::SetSession(const Arguments& args) { |
|
|
return ThrowException(Exception::Error(eStr)); |
|
|
return ThrowException(Exception::Error(eStr)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Handle<Value> Connection::LoadSession(const Arguments& args) { |
|
|
Handle<Value> Connection::LoadSession(const Arguments& args) { |
|
@ -1696,7 +1695,7 @@ Handle<Value> Connection::LoadSession(const Arguments& args) { |
|
|
|
|
|
|
|
|
ss->hello_parser_.Finish(); |
|
|
ss->hello_parser_.Finish(); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Handle<Value> Connection::IsSessionReused(const Arguments& args) { |
|
|
Handle<Value> Connection::IsSessionReused(const Arguments& args) { |
|
@ -1705,10 +1704,10 @@ Handle<Value> Connection::IsSessionReused(const Arguments& args) { |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL || SSL_session_reused(ss->ssl_) == false) { |
|
|
if (ss->ssl_ == NULL || SSL_session_reused(ss->ssl_) == false) { |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1727,10 +1726,10 @@ Handle<Value> Connection::Start(const Arguments& args) { |
|
|
ss->HandleSSLError("SSL_connect:Start", rv, kZeroIsAnError); |
|
|
ss->HandleSSLError("SSL_connect:Start", rv, kZeroIsAnError); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(rv, node_isolate)); |
|
|
return scope.Close(Integer::New(rv)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(0, node_isolate)); |
|
|
return scope.Close(Integer::New(0)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1739,12 +1738,12 @@ Handle<Value> Connection::Shutdown(const Arguments& args) { |
|
|
|
|
|
|
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL) return False(node_isolate); |
|
|
if (ss->ssl_ == NULL) return False(); |
|
|
int rv = SSL_shutdown(ss->ssl_); |
|
|
int rv = SSL_shutdown(ss->ssl_); |
|
|
ss->HandleSSLError("SSL_shutdown", rv, kZeroIsNotAnError); |
|
|
ss->HandleSSLError("SSL_shutdown", rv, kZeroIsNotAnError); |
|
|
ss->SetShutdownFlags(); |
|
|
ss->SetShutdownFlags(); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(rv, node_isolate)); |
|
|
return scope.Close(Integer::New(rv)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1753,12 +1752,12 @@ Handle<Value> Connection::ReceivedShutdown(const Arguments& args) { |
|
|
|
|
|
|
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL) return False(node_isolate); |
|
|
if (ss->ssl_ == NULL) return False(); |
|
|
int r = SSL_get_shutdown(ss->ssl_); |
|
|
int r = SSL_get_shutdown(ss->ssl_); |
|
|
|
|
|
|
|
|
if (r & SSL_RECEIVED_SHUTDOWN) return True(node_isolate); |
|
|
if (r & SSL_RECEIVED_SHUTDOWN) return True(); |
|
|
|
|
|
|
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1768,10 +1767,10 @@ Handle<Value> Connection::IsInitFinished(const Arguments& args) { |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL || SSL_is_init_finished(ss->ssl_) == false) { |
|
|
if (ss->ssl_ == NULL || SSL_is_init_finished(ss->ssl_) == false) { |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1780,7 +1779,7 @@ Handle<Value> Connection::VerifyError(const Arguments& args) { |
|
|
|
|
|
|
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
Connection *ss = Connection::Unwrap(args); |
|
|
|
|
|
|
|
|
if (ss->ssl_ == NULL) return Null(node_isolate); |
|
|
if (ss->ssl_ == NULL) return Null(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// XXX Do this check in JS land?
|
|
|
// XXX Do this check in JS land?
|
|
@ -1801,7 +1800,7 @@ Handle<Value> Connection::VerifyError(const Arguments& args) { |
|
|
|
|
|
|
|
|
switch (x509_verify_error) { |
|
|
switch (x509_verify_error) { |
|
|
case X509_V_OK: |
|
|
case X509_V_OK: |
|
|
return Null(node_isolate); |
|
|
return Null(); |
|
|
|
|
|
|
|
|
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: |
|
|
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: |
|
|
s = String::New("UNABLE_TO_GET_ISSUER_CERT"); |
|
|
s = String::New("UNABLE_TO_GET_ISSUER_CERT"); |
|
@ -1927,9 +1926,9 @@ Handle<Value> Connection::GetCurrentCipher(const Arguments& args) { |
|
|
|
|
|
|
|
|
OPENSSL_CONST SSL_CIPHER *c; |
|
|
OPENSSL_CONST SSL_CIPHER *c; |
|
|
|
|
|
|
|
|
if ( ss->ssl_ == NULL ) return Undefined(node_isolate); |
|
|
if ( ss->ssl_ == NULL ) return Undefined(); |
|
|
c = SSL_get_current_cipher(ss->ssl_); |
|
|
c = SSL_get_current_cipher(ss->ssl_); |
|
|
if ( c == NULL ) return Undefined(node_isolate); |
|
|
if ( c == NULL ) return Undefined(); |
|
|
Local<Object> info = Object::New(); |
|
|
Local<Object> info = Object::New(); |
|
|
const char* cipher_name = SSL_CIPHER_get_name(c); |
|
|
const char* cipher_name = SSL_CIPHER_get_name(c); |
|
|
info->Set(name_symbol, String::New(cipher_name)); |
|
|
info->Set(name_symbol, String::New(cipher_name)); |
|
@ -1947,7 +1946,7 @@ Handle<Value> Connection::Close(const Arguments& args) { |
|
|
SSL_free(ss->ssl_); |
|
|
SSL_free(ss->ssl_); |
|
|
ss->ssl_ = NULL; |
|
|
ss->ssl_ = NULL; |
|
|
} |
|
|
} |
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef OPENSSL_NPN_NEGOTIATED |
|
|
#ifdef OPENSSL_NPN_NEGOTIATED |
|
@ -1963,7 +1962,7 @@ Handle<Value> Connection::GetNegotiatedProto(const Arguments& args) { |
|
|
SSL_get0_next_proto_negotiated(ss->ssl_, &npn_proto, &npn_proto_len); |
|
|
SSL_get0_next_proto_negotiated(ss->ssl_, &npn_proto, &npn_proto_len); |
|
|
|
|
|
|
|
|
if (!npn_proto) { |
|
|
if (!npn_proto) { |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return String::New((const char*) npn_proto, npn_proto_len); |
|
|
return String::New((const char*) npn_proto, npn_proto_len); |
|
@ -1988,7 +1987,7 @@ Handle<Value> Connection::SetNPNProtocols(const Arguments& args) { |
|
|
} |
|
|
} |
|
|
ss->npnProtos_ = Persistent<Object>::New(args[0]->ToObject()); |
|
|
ss->npnProtos_ = Persistent<Object>::New(args[0]->ToObject()); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
}; |
|
|
}; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -2001,7 +2000,7 @@ Handle<Value> Connection::GetServername(const Arguments& args) { |
|
|
if (ss->is_server_ && !ss->servername_.IsEmpty()) { |
|
|
if (ss->is_server_ && !ss->servername_.IsEmpty()) { |
|
|
return ss->servername_; |
|
|
return ss->servername_; |
|
|
} else { |
|
|
} else { |
|
|
return False(node_isolate); |
|
|
return False(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2022,7 +2021,7 @@ Handle<Value> Connection::SetSNICallback(const Arguments& args) { |
|
|
ss->sniObject_ = Persistent<Object>::New(Object::New()); |
|
|
ss->sniObject_ = Persistent<Object>::New(Object::New()); |
|
|
ss->sniObject_->Set(String::New("onselect"), args[0]); |
|
|
ss->sniObject_->Set(String::New("onselect"), args[0]); |
|
|
|
|
|
|
|
|
return True(node_isolate); |
|
|
return True(); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -2256,7 +2255,7 @@ class Cipher : public ObjectWrap { |
|
|
|
|
|
|
|
|
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); |
|
|
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); |
|
|
|
|
|
|
|
|
return Undefined(node_isolate); |
|
|
return Undefined(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Handle<Value> CipherFinal(const Arguments& args) { |
|
|
static Handle<Value> CipherFinal(const Arguments& args) { |
|
@ -2570,7 +2569,7 @@ class Decipher : public ObjectWrap { |
|
|
|
|
|
|
|
|
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); |
|
|
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); |
|
|
|
|
|
|
|
|
return Undefined(node_isolate); |
|
|
return Undefined(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Handle<Value> DecipherFinal(const Arguments& args) { |
|
|
static Handle<Value> DecipherFinal(const Arguments& args) { |
|
@ -3719,12 +3718,12 @@ void EIO_PBKDF2(uv_work_t* work_req) { |
|
|
|
|
|
|
|
|
void EIO_PBKDF2After(pbkdf2_req* req, Local<Value> argv[2]) { |
|
|
void EIO_PBKDF2After(pbkdf2_req* req, Local<Value> argv[2]) { |
|
|
if (req->err) { |
|
|
if (req->err) { |
|
|
argv[0] = Local<Value>::New(node_isolate, Undefined(node_isolate)); |
|
|
argv[0] = Local<Value>::New(Undefined()); |
|
|
argv[1] = Encode(req->key, req->keylen, BUFFER); |
|
|
argv[1] = Encode(req->key, req->keylen, BUFFER); |
|
|
memset(req->key, 0, req->keylen); |
|
|
memset(req->key, 0, req->keylen); |
|
|
} else { |
|
|
} else { |
|
|
argv[0] = Exception::Error(String::New("PBKDF2 error")); |
|
|
argv[0] = Exception::Error(String::New("PBKDF2 error")); |
|
|
argv[1] = Local<Value>::New(node_isolate, Undefined(node_isolate)); |
|
|
argv[1] = Local<Value>::New(Undefined()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
delete[] req->pass; |
|
|
delete[] req->pass; |
|
@ -3826,7 +3825,7 @@ Handle<Value> PBKDF2(const Arguments& args) { |
|
|
&req->work_req, |
|
|
&req->work_req, |
|
|
EIO_PBKDF2, |
|
|
EIO_PBKDF2, |
|
|
EIO_PBKDF2After); |
|
|
EIO_PBKDF2After); |
|
|
return Undefined(node_isolate); |
|
|
return Undefined(); |
|
|
} else { |
|
|
} else { |
|
|
Local<Value> argv[2]; |
|
|
Local<Value> argv[2]; |
|
|
EIO_PBKDF2(req); |
|
|
EIO_PBKDF2(req); |
|
@ -3897,13 +3896,13 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) { |
|
|
ERR_error_string_n(req->error_, errmsg, sizeof errmsg); |
|
|
ERR_error_string_n(req->error_, errmsg, sizeof errmsg); |
|
|
|
|
|
|
|
|
argv[0] = Exception::Error(String::New(errmsg)); |
|
|
argv[0] = Exception::Error(String::New(errmsg)); |
|
|
argv[1] = Local<Value>::New(node_isolate, Null(node_isolate)); |
|
|
argv[1] = Local<Value>::New(Null()); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
// avoids the malloc + memcpy
|
|
|
// avoids the malloc + memcpy
|
|
|
Buffer* buffer = Buffer::New(req->data_, req->size_, RandomBytesFree, NULL); |
|
|
Buffer* buffer = Buffer::New(req->data_, req->size_, RandomBytesFree, NULL); |
|
|
argv[0] = Local<Value>::New(node_isolate, Null(node_isolate)); |
|
|
argv[0] = Local<Value>::New(Null()); |
|
|
argv[1] = Local<Object>::New(node_isolate, buffer->handle_); |
|
|
argv[1] = Local<Object>::New(buffer->handle_); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|