Skip to content

Commit

Permalink
crypto: trusted store first for cross root cert
Browse files Browse the repository at this point in the history
  • Loading branch information
Shigeki Ohtsu committed Jan 8, 2015
1 parent 396141e commit 2745b30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ Handle<Value> SecureContext::Init(const Arguments& args) {
SSL_CTX_sess_set_get_cb(sc->ctx_, GetSessionCallback);
SSL_CTX_sess_set_new_cb(sc->ctx_, NewSessionCallback);

X509_VERIFY_PARAM_set_flags(sc->param_, X509_V_FLAG_TRUSTED_FIRST);
SSL_CTX_set1_param(sc->ctx_, sc->param_);
sc->ca_store_ = NULL;
return True();
}
Expand Down Expand Up @@ -802,7 +804,7 @@ size_t ClientHelloParser::Write(const uint8_t* data, size_t len) {
HandleScope scope;

assert(state_ != kEnded);

// Just accumulate data, everything will be pushed to BIO later
if (state_ == kPaused) return 0;

Expand Down
3 changes: 3 additions & 0 deletions src/node_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SecureContext : ObjectWrap {
SSL_CTX *ctx_;
// TODO: ca_store_ should probably be removed, it's not used anywhere.
X509_STORE *ca_store_;
X509_VERIFY_PARAM *param_;

protected:
static const int kMaxSessionSize = 10 * 1024;
Expand All @@ -88,6 +89,7 @@ class SecureContext : ObjectWrap {
SecureContext() : ObjectWrap() {
ctx_ = NULL;
ca_store_ = NULL;
param_ = X509_VERIFY_PARAM_new();
}

void FreeCTXMem() {
Expand All @@ -102,6 +104,7 @@ class SecureContext : ObjectWrap {
SSL_CTX_free(ctx_);
ctx_ = NULL;
ca_store_ = NULL;
X509_VERIFY_PARAM_free(param_);
} else {
assert(ca_store_ == NULL);
}
Expand Down

0 comments on commit 2745b30

Please sign in to comment.