Browse Source

Move root certs out of JavaScript

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
4b947310b2
  1. 3590
      lib/crypto.js
  2. 33
      src/node_crypto.cc
  3. 1
      src/node_crypto.h
  4. 3594
      src/node_root_certs.h

3590
lib/crypto.js

File diff suppressed because it is too large

33
src/node_crypto.cc

@ -3,6 +3,7 @@
#include <node.h>
#include <node_buffer.h>
#include <node_root_certs.h>
#include <string.h>
#include <stdlib.h>
@ -41,6 +42,7 @@ void SecureContext::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "setKey", SecureContext::SetKey);
NODE_SET_PROTOTYPE_METHOD(t, "setCert", SecureContext::SetCert);
NODE_SET_PROTOTYPE_METHOD(t, "addCACert", SecureContext::AddCACert);
NODE_SET_PROTOTYPE_METHOD(t, "addRootCerts", SecureContext::AddRootCerts);
NODE_SET_PROTOTYPE_METHOD(t, "setCiphers", SecureContext::SetCiphers);
NODE_SET_PROTOTYPE_METHOD(t, "close", SecureContext::Close);
@ -207,6 +209,37 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
}
Handle<Value> SecureContext::AddRootCerts(const Arguments& args) {
HandleScope scope;
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
for (int i = 0; root_certs[i]; i++) {
// TODO: reuse bp ?
BIO *bp = BIO_new(BIO_s_mem());
if (!BIO_write(bp, root_certs[i], strlen(root_certs[i]))) {
BIO_free(bp);
return False();
}
X509 *x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL);
if (x509 == NULL) {
BIO_free(bp);
return False();
}
X509_STORE_add_cert(sc->ca_store_, x509);
BIO_free(bp);
X509_free(x509);
}
return True();
}
Handle<Value> SecureContext::SetCiphers(const Arguments& args) {
HandleScope scope;

1
src/node_crypto.h

@ -30,6 +30,7 @@ class SecureContext : ObjectWrap {
static v8::Handle<v8::Value> SetKey(const v8::Arguments& args);
static v8::Handle<v8::Value> SetCert(const v8::Arguments& args);
static v8::Handle<v8::Value> AddCACert(const v8::Arguments& args);
static v8::Handle<v8::Value> AddRootCerts(const v8::Arguments& args);
static v8::Handle<v8::Value> SetCiphers(const v8::Arguments& args);
static v8::Handle<v8::Value> Close(const v8::Arguments& args);

3594
src/node_root_certs.h

File diff suppressed because it is too large
Loading…
Cancel
Save