Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

crypto, tls: make setSNICallback() compatible with domains

  • Loading branch information...
commit 7dfa587d18c9d55cf2625c138250ef02c464d911 1 parent 7d0543c
@bnoordhuis bnoordhuis authored
Showing with 12 additions and 15 deletions.
  1. +10 −13 src/node_crypto.cc
  2. +2 −2 src/node_crypto.h
View
23 src/node_crypto.cc
@@ -938,23 +938,20 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
}
p->servername_ = Persistent<String>::New(String::New(servername));
- // Call sniCallback_ and use it's return value as context
- if (!p->sniCallback_.IsEmpty()) {
+ // Call the SNI callback and use its return value as context
+ if (!p->sniObject_.IsEmpty()) {
if (!p->sniContext_.IsEmpty()) {
p->sniContext_.Dispose();
}
// Get callback init args
Local<Value> argv[1] = {*p->servername_};
- Local<Function> callback = *p->sniCallback_;
// Call it
- //
- // XXX There should be an object connected to this that
- // we can attach a domain onto.
- Local<Value> ret;
- ret = Local<Value>::New(MakeCallback(Context::GetCurrent()->Global(),
- callback, ARRAY_SIZE(argv), argv));
+ Local<Value> ret = Local<Value>::New(MakeCallback(p->sniObject_,
+ "onselect",
+ ARRAY_SIZE(argv),
+ argv));
// If ret is SecureContext
if (secure_context_constructor->HasInstance(ret)) {
@@ -1774,11 +1771,11 @@ Handle<Value> Connection::SetSNICallback(const Arguments& args) {
}
// Release old handle
- if (!ss->sniCallback_.IsEmpty()) {
- ss->sniCallback_.Dispose();
+ if (!ss->sniObject_.IsEmpty()) {
+ ss->sniObject_.Dispose();
}
- ss->sniCallback_ = Persistent<Function>::New(
- Local<Function>::Cast(args[0]));
+ ss->sniObject_ = Persistent<Object>::New(Object::New());
+ ss->sniObject_->Set(String::New("onselect"), args[0]);
return True();
}
View
4 src/node_crypto.h
@@ -110,7 +110,7 @@ class Connection : ObjectWrap {
#endif
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
- v8::Persistent<v8::Function> sniCallback_;
+ v8::Persistent<v8::Object> sniObject_;
v8::Persistent<v8::Value> sniContext_;
v8::Persistent<v8::String> servername_;
#endif
@@ -185,7 +185,7 @@ class Connection : ObjectWrap {
#endif
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
- if (!sniCallback_.IsEmpty()) sniCallback_.Dispose();
+ if (!sniObject_.IsEmpty()) sniObject_.Dispose();
if (!sniContext_.IsEmpty()) sniContext_.Dispose();
if (!servername_.IsEmpty()) servername_.Dispose();
#endif

0 comments on commit 7dfa587

Please sign in to comment.
Something went wrong with that request. Please try again.