Move root certs out of JavaScript
This commit is contained in:
parent
09157369b3
commit
4b947310b2
3590
lib/crypto.js
3590
lib/crypto.js
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
||||
|
@ -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
Normal file
3594
src/node_root_certs.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user