Browse Source

Fix style in node_crypto.cc

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
9911629de0
  1. 10
      lib/net.js
  2. 251
      src/node_crypto.cc
  3. 26
      src/node_crypto.h

10
lib/net.js

@ -426,12 +426,10 @@ function setImplmentationMethods (self) {
allocNewSecurePool(); allocNewSecurePool();
} }
var secureLen = self.secureStream.encOut( var len = self.secureStream.encOut(securePool, 0, securePool.length);
securePool, 0, securePool.length
);
try { try {
oldWrite(securePool, 0, secureLen); oldWrite(securePool, 0, len);
} catch (e) { } } catch (e) { }
oldShutdown(); oldShutdown();
@ -560,8 +558,8 @@ Stream.prototype.setSecure = function (credentials) {
this.credentials.shouldVerify = true; this.credentials.shouldVerify = true;
} }
this.secureStream = new SecureStream(this.credentials.context, this.secureStream = new SecureStream(this.credentials.context,
this.server ? 1 : 0, this.server ? true : false,
this.credentials.shouldVerify ? 1 : 0); this.credentials.shouldVerify);
setImplmentationMethods(this); setImplmentationMethods(this);

251
src/node_crypto.cc

@ -100,13 +100,13 @@ Handle<Value> SecureContext::Init(const Arguments& args) {
method = TLSv1_client_method(); method = TLSv1_client_method();
} }
sc->pCtx = SSL_CTX_new(method); sc->ctx_ = SSL_CTX_new(method);
// Enable session caching? // Enable session caching?
SSL_CTX_set_session_cache_mode(sc->pCtx, SSL_SESS_CACHE_SERVER); SSL_CTX_set_session_cache_mode(sc->ctx_, SSL_SESS_CACHE_SERVER);
// SSL_CTX_set_session_cache_mode(sc->pCtx,SSL_SESS_CACHE_OFF); // SSL_CTX_set_session_cache_mode(sc->ctx_,SSL_SESS_CACHE_OFF);
sc->caStore = X509_STORE_new(); sc->ca_store_ = X509_STORE_new();
SSL_CTX_set_cert_store(sc->pCtx, sc->caStore); SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_);
return True(); return True();
} }
@ -116,25 +116,29 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) {
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
if (args.Length() != 1 || if (args.Length() != 1 || !args[0]->IsString()) {
!args[0]->IsString()) { return ThrowException(Exception::TypeError(String::New("Bad parameter")));
return ThrowException(Exception::TypeError(
String::New("Bad parameter")));
} }
String::Utf8Value keyPem(args[0]->ToString());
BIO *bp = NULL; String::Utf8Value key_pem(args[0]->ToString());
EVP_PKEY* pkey;
bp = BIO_new(BIO_s_mem()); BIO *bp = BIO_new(BIO_s_mem());
if (!BIO_write(bp, *keyPem, strlen(*keyPem)))
if (!BIO_write(bp, *key_pem, key_pem.length())) {
BIO_free(bp);
return False(); return False();
}
EVP_PKEY* pkey = PEM_read_bio_PrivateKey(bp, NULL, NULL, NULL);
pkey = PEM_read_bio_PrivateKey(bp, NULL, NULL, NULL); if (pkey == NULL) {
if (pkey == NULL) BIO_free(bp);
return False(); return False();
}
SSL_CTX_use_PrivateKey(sc->pCtx, pkey); SSL_CTX_use_PrivateKey(sc->ctx_, pkey);
BIO_free(bp); BIO_free(bp);
// XXX Free pkey?
return True(); return True();
} }
@ -150,19 +154,24 @@ Handle<Value> SecureContext::SetCert(const Arguments& args) {
return ThrowException(Exception::TypeError( return ThrowException(Exception::TypeError(
String::New("Bad parameter"))); String::New("Bad parameter")));
} }
String::Utf8Value certPem(args[0]->ToString()); String::Utf8Value cert_pem(args[0]->ToString());
BIO *bp = NULL; BIO *bp = BIO_new(BIO_s_mem());
X509 * x509;
bp = BIO_new(BIO_s_mem()); if (!BIO_write(bp, *cert_pem, cert_pem.length())) {
if (!BIO_write(bp, *certPem, strlen(*certPem))) BIO_free(bp);
return False(); return False();
}
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);
return False(); return False();
}
SSL_CTX_use_certificate(sc->ctx_, x509);
SSL_CTX_use_certificate(sc->pCtx, x509);
BIO_free(bp); BIO_free(bp);
X509_free(x509); X509_free(x509);
@ -175,24 +184,26 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
if (args.Length() != 1 || if (args.Length() != 1 || !args[0]->IsString()) {
!args[0]->IsString()) { return ThrowException(Exception::TypeError(String::New("Bad parameter")));
return ThrowException(Exception::TypeError(
String::New("Bad parameter")));
} }
String::Utf8Value certPem(args[0]->ToString()); String::Utf8Value cert_pem(args[0]->ToString());
BIO *bp = BIO_new(BIO_s_mem());
BIO *bp = NULL; if (!BIO_write(bp, *cert_pem, cert_pem.length())) {
X509 *x509; BIO_free(bp);
bp = BIO_new(BIO_s_mem());
if (!BIO_write(bp, *certPem, strlen(*certPem)))
return False(); return False();
}
X509 *x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL);
x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL); if (x509 == NULL) {
if (x509 == NULL) BIO_free(bp);
return False(); return False();
}
X509_STORE_add_cert(sc->caStore, x509); X509_STORE_add_cert(sc->ca_store_, x509);
BIO_free(bp); BIO_free(bp);
X509_free(x509); X509_free(x509);
@ -206,13 +217,12 @@ Handle<Value> SecureContext::SetCiphers(const Arguments& args) {
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
if (args.Length() != 1 || if (args.Length() != 1 || !args[0]->IsString()) {
!args[0]->IsString()) { return ThrowException(Exception::TypeError(String::New("Bad parameter")));
return ThrowException(Exception::TypeError(
String::New("Bad parameter")));
} }
String::Utf8Value ciphers(args[0]->ToString()); String::Utf8Value ciphers(args[0]->ToString());
SSL_CTX_set_cipher_list(sc->pCtx, *ciphers); SSL_CTX_set_cipher_list(sc->ctx_, *ciphers);
return True(); return True();
} }
@ -223,10 +233,11 @@ Handle<Value> SecureContext::Close(const Arguments& args) {
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
if (sc->pCtx != NULL) { if (sc->ctx_ != NULL) {
SSL_CTX_free(sc->pCtx); SSL_CTX_free(sc->ctx_);
return True(); return True();
} }
return False(); return False();
} }
@ -238,30 +249,18 @@ void SecureStream::Initialize(Handle<Object> target) {
t->InstanceTemplate()->SetInternalFieldCount(1); t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(String::NewSymbol("SecureStream")); t->SetClassName(String::NewSymbol("SecureStream"));
NODE_SET_PROTOTYPE_METHOD(t, "encIn", NODE_SET_PROTOTYPE_METHOD(t, "encIn", SecureStream::EncIn);
SecureStream::EncIn); NODE_SET_PROTOTYPE_METHOD(t, "clearOut", SecureStream::ClearOut);
NODE_SET_PROTOTYPE_METHOD(t, "clearOut", NODE_SET_PROTOTYPE_METHOD(t, "clearIn", SecureStream::ClearIn);
SecureStream::ClearOut); NODE_SET_PROTOTYPE_METHOD(t, "encOut", SecureStream::EncOut);
NODE_SET_PROTOTYPE_METHOD(t, "clearIn", NODE_SET_PROTOTYPE_METHOD(t, "clearPending", SecureStream::ClearPending);
SecureStream::ClearIn); NODE_SET_PROTOTYPE_METHOD(t, "encPending", SecureStream::EncPending);
NODE_SET_PROTOTYPE_METHOD(t, "encOut", NODE_SET_PROTOTYPE_METHOD(t, "getPeerCertificate", SecureStream::GetPeerCertificate);
SecureStream::EncOut); NODE_SET_PROTOTYPE_METHOD(t, "isInitFinished", SecureStream::IsInitFinished);
NODE_SET_PROTOTYPE_METHOD(t, "clearPending", NODE_SET_PROTOTYPE_METHOD(t, "verifyPeer", SecureStream::VerifyPeer);
SecureStream::ClearPending); NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher", SecureStream::GetCurrentCipher);
NODE_SET_PROTOTYPE_METHOD(t, "encPending", NODE_SET_PROTOTYPE_METHOD(t, "shutdown", SecureStream::Shutdown);
SecureStream::EncPending); NODE_SET_PROTOTYPE_METHOD(t, "close", SecureStream::Close);
NODE_SET_PROTOTYPE_METHOD(t, "getPeerCertificate",
SecureStream::GetPeerCertificate);
NODE_SET_PROTOTYPE_METHOD(t, "isInitFinished",
SecureStream::IsInitFinished);
NODE_SET_PROTOTYPE_METHOD(t, "verifyPeer",
SecureStream::VerifyPeer);
NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher",
SecureStream::GetCurrentCipher);
NODE_SET_PROTOTYPE_METHOD(t, "shutdown",
SecureStream::Shutdown);
NODE_SET_PROTOTYPE_METHOD(t, "close",
SecureStream::Close);
target->Set(String::NewSymbol("SecureStream"), t->GetFunction()); target->Set(String::NewSymbol("SecureStream"), t->GetFunction());
} }
@ -269,39 +268,33 @@ void SecureStream::Initialize(Handle<Object> target) {
Handle<Value> SecureStream::New(const Arguments& args) { Handle<Value> SecureStream::New(const Arguments& args) {
HandleScope scope; HandleScope scope;
SecureStream *p = new SecureStream(); SecureStream *p = new SecureStream();
p->Wrap(args.Holder()); p->Wrap(args.Holder());
if (args.Length() <1 || if (args.Length() < 1 || !args[0]->IsObject()) {
!args[0]->IsObject()) {
return ThrowException(Exception::Error(String::New( return ThrowException(Exception::Error(String::New(
"First argument must be a crypto module Credentials"))); "First argument must be a crypto module Credentials")));
} }
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args[0]->ToObject()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args[0]->ToObject());
int isServer = 0;
int shouldVerify = 0; bool is_server = args[1]->BooleanValue();
if (args.Length() >=2 && bool should_verify = args[2]->BooleanValue();
args[1]->IsNumber()) {
isServer = args[1]->Int32Value(); p->ssl_ = SSL_new(sc->ctx_);
} p->bio_read_ = BIO_new(BIO_s_mem());
if (args.Length() >=3 && p->bio_write_ = BIO_new(BIO_s_mem());
args[2]->IsNumber()) { SSL_set_bio(p->ssl_, p->bio_read_, p->bio_write_);
shouldVerify = args[2]->Int32Value();
} if (p->should_verify_ = should_verify) {
SSL_set_verify(p->ssl_, SSL_VERIFY_PEER, verify_callback);
p->pSSL = SSL_new(sc->pCtx); }
p->pbioRead = BIO_new(BIO_s_mem());
p->pbioWrite = BIO_new(BIO_s_mem()); if (p->is_server_ = is_server) {
SSL_set_bio(p->pSSL, p->pbioRead, p->pbioWrite); SSL_set_accept_state(p->ssl_);
p->shouldVerify = shouldVerify>0;
if (p->shouldVerify) {
SSL_set_verify(p->pSSL, SSL_VERIFY_PEER, verify_callback);
}
p->server = isServer>0;
if (p->server) {
SSL_set_accept_state(p->pSSL);
} else { } else {
SSL_set_connect_state(p->pSSL); SSL_set_connect_state(p->ssl_);
} }
return args.This(); return args.This();
@ -339,7 +332,7 @@ Handle<Value> SecureStream::EncIn(const Arguments& args) {
String::New("Length is extends beyond buffer"))); String::New("Length is extends beyond buffer")));
} }
int bytes_written = BIO_write(ss->pbioRead, (char*)buffer_data + off, len); int bytes_written = BIO_write(ss->bio_read_, (char*)buffer_data + off, len);
if (bytes_written < 0) { if (bytes_written < 0) {
if (errno == EAGAIN || errno == EINTR) return Null(); if (errno == EAGAIN || errno == EINTR) return Null();
@ -383,24 +376,24 @@ Handle<Value> SecureStream::ClearOut(const Arguments& args) {
int bytes_read; int bytes_read;
if (!SSL_is_init_finished(ss->pSSL)) { if (!SSL_is_init_finished(ss->ssl_)) {
if (ss->server) { if (ss->is_server_) {
bytes_read = SSL_accept(ss->pSSL); bytes_read = SSL_accept(ss->ssl_);
} else { } else {
bytes_read = SSL_connect(ss->pSSL); bytes_read = SSL_connect(ss->ssl_);
} }
if (bytes_read < 0) { if (bytes_read < 0) {
int err; int err;
if ((err = SSL_get_error(ss->pSSL, bytes_read)) == SSL_ERROR_WANT_READ) { if ((err = SSL_get_error(ss->ssl_, bytes_read)) == SSL_ERROR_WANT_READ) {
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0));
} }
} }
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0));
} }
bytes_read = SSL_read(ss->pSSL, (char*)buffer_data + off, len); bytes_read = SSL_read(ss->ssl_, (char*)buffer_data + off, len);
if (bytes_read < 0) { if (bytes_read < 0) {
int err = SSL_get_error(ss->pSSL, bytes_read); int err = SSL_get_error(ss->ssl_, bytes_read);
if (err == SSL_ERROR_WANT_READ) { if (err == SSL_ERROR_WANT_READ) {
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0));
} }
@ -421,7 +414,7 @@ Handle<Value> SecureStream::ClearPending(const Arguments& args) {
HandleScope scope; HandleScope scope;
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
int bytes_pending = BIO_pending(ss->pbioRead); int bytes_pending = BIO_pending(ss->bio_read_);
return scope.Close(Integer::New(bytes_pending)); return scope.Close(Integer::New(bytes_pending));
} }
@ -430,7 +423,7 @@ Handle<Value> SecureStream::EncPending(const Arguments& args) {
HandleScope scope; HandleScope scope;
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
int bytes_pending = BIO_pending(ss->pbioWrite); int bytes_pending = BIO_pending(ss->bio_write_);
return scope.Close(Integer::New(bytes_pending)); return scope.Close(Integer::New(bytes_pending));
} }
@ -466,7 +459,7 @@ Handle<Value> SecureStream::EncOut(const Arguments& args) {
String::New("Length is extends beyond buffer"))); String::New("Length is extends beyond buffer")));
} }
int bytes_read = BIO_read(ss->pbioWrite, (char*)buffer_data + off, len); int bytes_read = BIO_read(ss->bio_write_, (char*)buffer_data + off, len);
return scope.Close(Integer::New(bytes_read)); return scope.Close(Integer::New(bytes_read));
} }
@ -503,16 +496,16 @@ Handle<Value> SecureStream::ClearIn(const Arguments& args) {
String::New("Length is extends beyond buffer"))); String::New("Length is extends beyond buffer")));
} }
if (!SSL_is_init_finished(ss->pSSL)) { if (!SSL_is_init_finished(ss->ssl_)) {
int s; int s;
if (ss->server) { if (ss->is_server_) {
s = SSL_accept(ss->pSSL); s = SSL_accept(ss->ssl_);
} else { } else {
s = SSL_connect(ss->pSSL); s = SSL_connect(ss->ssl_);
} }
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0));
} }
int bytes_written = SSL_write(ss->pSSL, (char*)buffer_data + off, len); int bytes_written = SSL_write(ss->ssl_, (char*)buffer_data + off, len);
return scope.Close(Integer::New(bytes_written)); return scope.Close(Integer::New(bytes_written));
} }
@ -523,9 +516,9 @@ Handle<Value> SecureStream::GetPeerCertificate(const Arguments& args) {
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->pSSL == NULL) return Undefined(); if (ss->ssl_ == NULL) return Undefined();
Local<Object> info = Object::New(); Local<Object> info = Object::New();
X509* peer_cert = SSL_get_peer_certificate(ss->pSSL); X509* peer_cert = SSL_get_peer_certificate(ss->ssl_);
if (peer_cert != NULL) { if (peer_cert != NULL) {
char* subject = X509_NAME_oneline(X509_get_subject_name(peer_cert), 0, 0); char* subject = X509_NAME_oneline(X509_get_subject_name(peer_cert), 0, 0);
if (subject != NULL) { if (subject != NULL) {
@ -582,8 +575,8 @@ Handle<Value> SecureStream::Shutdown(const Arguments& args) {
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->pSSL == NULL) return False(); if (ss->ssl_ == NULL) return False();
if (SSL_shutdown(ss->pSSL) == 1) { if (SSL_shutdown(ss->ssl_) == 1) {
return True(); return True();
} }
return False(); return False();
@ -595,8 +588,8 @@ Handle<Value> SecureStream::IsInitFinished(const Arguments& args) {
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->pSSL == NULL) return False(); if (ss->ssl_ == NULL) return False();
if (SSL_is_init_finished(ss->pSSL)) { if (SSL_is_init_finished(ss->ssl_)) {
return True(); return True();
} }
return False(); return False();
@ -608,13 +601,13 @@ Handle<Value> SecureStream::VerifyPeer(const Arguments& args) {
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->pSSL == NULL) return False(); if (ss->ssl_ == NULL) return False();
if (!ss->shouldVerify) return False(); if (!ss->should_verify_) return False();
X509* peer_cert = SSL_get_peer_certificate(ss->pSSL); X509* peer_cert = SSL_get_peer_certificate(ss->ssl_);
if (peer_cert==NULL) return False(); if (peer_cert==NULL) return False();
X509_free(peer_cert); X509_free(peer_cert);
long x509_verify_error = SSL_get_verify_result(ss->pSSL); long x509_verify_error = SSL_get_verify_result(ss->ssl_);
// Can also check for: // Can also check for:
// X509_V_ERR_CERT_HAS_EXPIRED // X509_V_ERR_CERT_HAS_EXPIRED
@ -638,8 +631,8 @@ Handle<Value> SecureStream::GetCurrentCipher(const Arguments& args) {
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
OPENSSL_CONST SSL_CIPHER *c; OPENSSL_CONST SSL_CIPHER *c;
if ( ss->pSSL == NULL ) return Undefined(); if ( ss->ssl_ == NULL ) return Undefined();
c = SSL_get_current_cipher(ss->pSSL); c = SSL_get_current_cipher(ss->ssl_);
if ( c == NULL ) return Undefined(); 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);
@ -654,9 +647,9 @@ Handle<Value> SecureStream::Close(const Arguments& args) {
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder()); SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->pSSL != NULL) { if (ss->ssl_ != NULL) {
SSL_free(ss->pSSL); SSL_free(ss->ssl_);
ss->pSSL = NULL; ss->ssl_ = NULL;
} }
return True(); return True();
} }
@ -1961,14 +1954,14 @@ class Sign : public ObjectWrap {
int SignFinal(unsigned char** md_value, int SignFinal(unsigned char** md_value,
unsigned int *md_len, unsigned int *md_len,
char* keyPem, char* key_pem,
int keyPemLen) { int key_pemLen) {
if (!initialised_) return 0; if (!initialised_) return 0;
BIO *bp = NULL; BIO *bp = NULL;
EVP_PKEY* pkey; EVP_PKEY* pkey;
bp = BIO_new(BIO_s_mem()); bp = BIO_new(BIO_s_mem());
if(!BIO_write(bp, keyPem, keyPemLen)) return 0; if(!BIO_write(bp, key_pem, key_pemLen)) return 0;
pkey = PEM_read_bio_PrivateKey( bp, NULL, NULL, NULL ); pkey = PEM_read_bio_PrivateKey( bp, NULL, NULL, NULL );
if (pkey == NULL) return 0; if (pkey == NULL) return 0;
@ -2152,7 +2145,7 @@ class Verify : public ObjectWrap {
} }
int VerifyFinal(char* keyPem, int keyPemLen, unsigned char* sig, int siglen) { int VerifyFinal(char* key_pem, int key_pemLen, unsigned char* sig, int siglen) {
if (!initialised_) return 0; if (!initialised_) return 0;
BIO *bp = NULL; BIO *bp = NULL;
@ -2160,7 +2153,7 @@ class Verify : public ObjectWrap {
X509 *x509; X509 *x509;
bp = BIO_new(BIO_s_mem()); bp = BIO_new(BIO_s_mem());
if(!BIO_write(bp, keyPem, keyPemLen)) return 0; if(!BIO_write(bp, key_pem, key_pemLen)) return 0;
x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL ); x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL );
if (x509==NULL) return 0; if (x509==NULL) return 0;

26
src/node_crypto.h

@ -21,8 +21,8 @@ class SecureContext : ObjectWrap {
public: public:
static void Initialize(v8::Handle<v8::Object> target); static void Initialize(v8::Handle<v8::Object> target);
SSL_CTX *pCtx; SSL_CTX *ctx_;
X509_STORE *caStore; X509_STORE *ca_store_;
protected: protected:
static v8::Handle<v8::Value> New(const v8::Arguments& args); static v8::Handle<v8::Value> New(const v8::Arguments& args);
@ -34,8 +34,8 @@ class SecureContext : ObjectWrap {
static v8::Handle<v8::Value> Close(const v8::Arguments& args); static v8::Handle<v8::Value> Close(const v8::Arguments& args);
SecureContext() : ObjectWrap() { SecureContext() : ObjectWrap() {
pCtx = NULL; ctx_ = NULL;
caStore = NULL; ca_store_ = NULL;
} }
~SecureContext() { ~SecureContext() {
@ -65,19 +65,23 @@ class SecureStream : ObjectWrap {
static v8::Handle<v8::Value> Close(const v8::Arguments& args); static v8::Handle<v8::Value> Close(const v8::Arguments& args);
SecureStream() : ObjectWrap() { SecureStream() : ObjectWrap() {
pbioRead = pbioWrite = NULL; bio_read_ = bio_write_ = NULL;
pSSL = NULL; ssl_ = NULL;
} }
~SecureStream() { ~SecureStream() {
if (ssl_ != NULL) {
SSL_free(ssl_);
ssl_ = NULL;
}
} }
private: private:
BIO *pbioRead; BIO *bio_read_;
BIO *pbioWrite; BIO *bio_write_;
SSL *pSSL; SSL *ssl_;
bool server; /* coverity[member_decl] */ bool is_server_; /* coverity[member_decl] */
bool shouldVerify; /* coverity[member_decl] */ bool should_verify_; /* coverity[member_decl] */
}; };
void InitCrypto(v8::Handle<v8::Object> target); void InitCrypto(v8::Handle<v8::Object> target);

Loading…
Cancel
Save