Browse Source

TLS: CRL support

Needs more tests.
v0.7.4-release
Theo Schlossnagle 14 years ago
committed by Ryan Dahl
parent
commit
01a864a29d
  1. 10
      lib/crypto.js
  2. 9
      lib/tls.js
  3. 32
      src/node_crypto.cc
  4. 1
      src/node_crypto.h
  5. 23
      test/fixtures/keys/Makefile
  6. 14
      test/fixtures/keys/agent3-cert.pem
  7. 8
      test/fixtures/keys/agent3-csr.pem
  8. 14
      test/fixtures/keys/agent3-key.pem
  9. 18
      test/fixtures/keys/agent4-cert.pem
  10. 8
      test/fixtures/keys/agent4-csr.pem
  11. 14
      test/fixtures/keys/agent4-key.pem
  12. 16
      test/fixtures/keys/ca2-cert.pem
  13. 2
      test/fixtures/keys/ca2-cert.srl
  14. 10
      test/fixtures/keys/ca2-crl.pem
  15. 1
      test/fixtures/keys/ca2-database.txt
  16. 30
      test/fixtures/keys/ca2-key.pem
  17. 1
      test/fixtures/keys/ca2-serial
  18. 13
      test/fixtures/keys/ca2.cnf
  19. 32
      test/simple/test-tls-server-verify.js

10
lib/crypto.js

@ -57,6 +57,16 @@ exports.createCredentials = function(options) {
c.context.addRootCerts();
}
if (options.crl) {
if (Array.isArray(options.crl)) {
for(var i = 0, len = options.crl.length; i < len; i++) {
c.context.addCRL(options.crl[i]);
}
} else {
c.context.addCRL(options.crl);
}
}
return c;
};

9
lib/tls.js

@ -656,8 +656,12 @@ function Server(/* [options], listener */) {
// constructor call
net.Server.call(this, function(socket) {
var creds = crypto.createCredentials(
{ key: self.key, cert: self.cert, ca: self.ca });
var creds = crypto.createCredentials({
key: self.key,
cert: self.cert,
ca: self.ca,
crl: self.crl
});
//creds.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
var pair = new SecurePair(creds,
@ -725,6 +729,7 @@ Server.prototype.setOptions = function(options) {
if (options.key) this.key = options.key;
if (options.cert) this.cert = options.cert;
if (options.ca) this.ca = options.ca;
if (options.crl) this.crl = options.crl;
};

32
src/node_crypto.cc

@ -44,6 +44,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, "addCRL", SecureContext::AddCRL);
NODE_SET_PROTOTYPE_METHOD(t, "addRootCerts", SecureContext::AddRootCerts);
NODE_SET_PROTOTYPE_METHOD(t, "setCiphers", SecureContext::SetCiphers);
NODE_SET_PROTOTYPE_METHOD(t, "close", SecureContext::Close);
@ -303,6 +304,37 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
}
Handle<Value> SecureContext::AddCRL(const Arguments& args) {
HandleScope scope;
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
if (args.Length() != 1) {
return ThrowException(Exception::TypeError(String::New("Bad parameter")));
}
BIO *bio = LoadBIO(args[0]);
if (!bio) return False();
X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL);
if (x509 == NULL) {
BIO_free(bio);
return False();
}
X509_STORE_add_crl(sc->ca_store_, x509);
X509_STORE_set_flags(sc->ca_store_, X509_V_FLAG_CRL_CHECK |
X509_V_FLAG_CRL_CHECK_ALL);
BIO_free(bio);
X509_CRL_free(x509);
return True();
}
Handle<Value> SecureContext::AddRootCerts(const Arguments& args) {
HandleScope scope;

1
src/node_crypto.h

@ -31,6 +31,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> AddCRL(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);

23
test/fixtures/keys/Makefile

@ -1,4 +1,4 @@
all: agent1-cert.pem agent2-cert.pem agent3-cert.pem agent4-cert.pem
all: agent1-cert.pem agent2-cert.pem agent3-cert.pem agent4-cert.pem ca2-crl.pem
#
@ -14,6 +14,8 @@ ca1-cert.pem: ca1.cnf
#
ca2-cert.pem: ca2.cnf
openssl req -new -x509 -config ca2.cnf -keyout ca2-key.pem -out ca2-cert.pem
echo '01' > ca2-serial
touch ca2-database.txt
#
@ -111,12 +113,23 @@ agent4-cert.pem: agent4-csr.pem ca2-cert.pem ca2-key.pem
agent4-verify: agent4-cert.pem ca2-cert.pem
openssl verify -CAfile ca2-cert.pem agent4-cert.pem
# TODO: agent on CRL
#
# Make CRL with agent4 being rejected
#
ca2-crl.pem: ca2-key.pem ca2-cert.pem ca2.cnf
openssl ca -revoke agent4-cert.pem \
-keyfile ca2-key.pem \
-cert ca2-cert.pem \
-config ca2.cnf
openssl ca \
-keyfile ca2-key.pem \
-cert ca2-cert.pem \
-config ca2.cnf \
-gencrl \
-out ca2-crl.pem
clean:
rm -f *.pem *.srl
rm -f *.pem *.srl ca2-database.txt ca2-serial
test: agent1-verify agent2-verify agent3-verify agent4-verify

14
test/fixtures/keys/agent3-cert.pem

@ -1,14 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICKjCCAZMCCQC9jzMlG+W8DDANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV
MIICKjCCAZMCCQDMRmF28ReZjTANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV
UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO
BgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMjEgMB4GCSqGSIb3DQEJARYRcnlA
dGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDIzMDIwWhcNMTMxMTA1MDIzMDIwWjB9
dGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDc1NjU1WhcNMTMxMTA1MDc1NjU1WjB9
MQswC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I40LekBKJsZfns6vftRGlwb7URt55Efx9QbBbONwMWHDKbGYA5GPAgMBAAEwDQYJ
KoZIhvcNAQEFBQADgYEAeQzT6q8xuxUuQ9tmZEjq6vHaUaU2gq5Zp48XBJg3XjNI
sxQEy1LreOR48THhS7QrKFELDGfr4bd6gPE0IvEpwAVu6eNNX/ZkrkiE2480W7CY
8hJMtYGXRi09BOSXnpSy0qMh63wjA3v5tTs+DPSwfi3xPsx8RyIz/hBXazoAKAM=
MIGJAoGBAMf9gxkjRyoHsgvya+jMlHRRds6qwt43t6tB6tkB6dW/23HBvXOCuHe0
Ryn2EofWtNaLg6IfJg8JwM6k39/EvGgjr730WeI2iQt2b7+OmBBLiEr+Xkrkeskp
Wv+3TdbwF08Vh4pV34kPQhD+q2d0PBZUGgBUVhVzcwZ4XWWJDq1DAgMBAAEwDQYJ
KoZIhvcNAQEFBQADgYEArEYmxp6S+LRE6Nu7ULVElCXL1ouR+srM03j25D/2G/6O
lryRDHGTsNUytBhQFghwi1vPB8mHTVLpWV9NgTbQrQF4qjQHY6CzcM2gnNfkmWql
mpR3x4hs25a86KR3OzrAx4JOkpvzEf1PJgWOLaKt38JoPxehvhgNMx1sd+MR8kw=
-----END CERTIFICATE-----

2
test/fixtures/keys/ca2-cert.srl

@ -1 +1 @@
BD8F33251BE5BC0D
CC466176F117998E

10
test/fixtures/keys/ca2-crl.pem

@ -0,0 +1,10 @@
-----BEGIN X509 CRL-----
MIIBXTCBxzANBgkqhkiG9w0BAQQFADB6MQswCQYDVQQGEwJVUzELMAkGA1UECBMC
Q0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAOBgNVBAsTB05vZGUu
anMxDDAKBgNVBAMTA2NhMjEgMB4GCSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5v
cmcXDTExMDIxMDA3NTcxMVoXDTEzMTEwNTA3NTcxMVowHDAaAgkAzEZhdvEXmY4X
DTExMDIxMDA3NTY1N1owDQYJKoZIhvcNAQEEBQADgYEAgH9u/zWn48ycNmJezW57
E54QQI2KqwqmnO1S0lt6EDhjktCAxgljoEhjb3rS3221jddbb9FckYVVMKVX3rPP
cUPXF1jLJ8I/jF0mETK4sZQPjA/PIzPQOnUzzQmszfr42b+5x6HQ0gg2RTqN1TC2
wLLY7ihxVXUzhVIHlGIp9Hk=
-----END X509 CRL-----

1
test/fixtures/keys/ca2-database.txt

@ -0,0 +1 @@
R 131105075655Z 110210075657Z CC466176F117998E unknown /C=US/ST=CA/L=SF/O=Joyent/OU=Node.js/CN=agent4/emailAddress=ry@tinyclouds.org

30
test/fixtures/keys/ca2-key.pem

@ -1,17 +1,17 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIg0hLO3eutNQCAggA
MBQGCCqGSIb3DQMHBAiRtZu32UxWpwSCAoCud1+Lak/kkrYxcdTeNh4RBQwpuEjv
fdoshPagoLVkp8hHWVPfIVJWI3AwjyPtQShusGZwTyjiDF7k6ycTZSNH6+nuc8K2
ZNGwPFWMEaO510tcraDf/H8yNbeThTvYkudQLwTRseZw3NmuBBkPEThYkJrBibsJ
Z8BsZ0y9FWgF+ufx7sGCC0Dq/Dd/JBGV7Kx75Vm65CpKkTV7W3tMXWa38yER8dBE
1vCexF95ih5zXbsRMlBoA0p45QD+0LrHssCSe+iuNAowvX/YHdfrcFRuvHkazzql
5j4sxs4647F+U1CTsb2+7C0LlijZBuP0x9GUsJck8M9Zh0s9sfwPbSofjZWhFcdR
liy7lxfyFdIbLav1cTfilT06BoyLLRUFp5Zu1XPCdxrf0pHoDjgXO/ToEjhStctM
RyVigOIQY+2yvgnzE/cw5niQlXDWDAnsSibYpjU8lJ1k97Iqx/qogqNSTIim8ml4
h7aDPHEBlGG9wmTkPV5L18/wI7iGom9rroQFrkgrqQ2JoIAKCXrocDKUjFAVB7QA
mreUdYowm6ee/AUdtsYQpn5hasIa/A/fD/Ia9E41rkplZZS43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1n8xepdgCE0rWSkbxoCmoKDXQDl1kOfs5TWIvL
JRqrVYz2yoPAa1Q9gTM3iDtBL3RJwF2jXk4IDySR/1YDf+BbnyhiisIRSMp8GeQS
uX1Ke+bu3QWwFVqa0eYScVPZZzNUADHzviMweRX9l+1aCw0R31po7Fwl
-----END ENCRYPTED PRIVATE KEY-----

1
test/fixtures/keys/ca2-serial

@ -0,0 +1 @@
01

13
test/fixtures/keys/ca2.cnf

@ -1,3 +1,16 @@
[ ca ]
default_ca = CA_default
[ CA_default ]
serial = ca2-serial
crl = ca2-crl.pem
database = ca2-database.txt
name_opt = CA_default
cert_opt = CA_default
default_crl_days = 999
default_md = md5
[ req ]
default_bits = 1024
days = 999

32
test/simple/test-tls-server-verify.js

@ -59,6 +59,22 @@ var testCases =
{ name: 'nocert', shouldReject: true }
]
},
{ title: "Allow only certs signed by CA2 but not in the CRL",
requestCert: true,
rejectUnauthorized: true,
CAs: ['ca2-cert'],
crl: 'ca2-crl',
clients:
[ { name: 'agent1', shouldReject: true, shouldAuth: false },
{ name: 'agent2', shouldReject: true, shouldAuth: false },
{ name: 'agent3', shouldReject: false, shouldAuth: true },
// Agent4 has a cert in the CRL.
{ name: 'agent4', shouldReject: true, shouldAuth: false },
{ name: 'nocert', shouldReject: true }
]
},
];
@ -92,6 +108,9 @@ function runClient (options, cb) {
var args = ['s_client', '-connect', '127.0.0.1:' + common.PORT];
console.log(" connecting with", options.name);
switch (options.name) {
case 'agent1':
// Signed by CA1
@ -118,6 +137,14 @@ function runClient (options, cb) {
args.push(filenamePEM('agent3-cert'));
break;
case 'agent4':
// Signed by CA2 (rejected by ca2-crl)
args.push('-key');
args.push(filenamePEM('agent4-key'));
args.push('-cert');
args.push(filenamePEM('agent4-cert'));
break;
case 'nocert':
// Do not send certificate
break;
@ -182,10 +209,13 @@ function runTest (testIndex) {
var cas = tcase.CAs.map(loadPEM);
var crl = tcase.crl ? loadPEM(tcase.crl) : null;
var serverOptions = {
key: serverKey,
cert: serverCert,
ca: cas,
crl: crl,
requestCert: tcase.requestCert,
rejectUnauthorized: tcase.rejectUnauthorized
};
@ -204,7 +234,7 @@ function runTest (testIndex) {
}
});
function runNextClient (clientIndex) {
function runNextClient(clientIndex) {
var options = tcase.clients[clientIndex];
if (options) {
runClient(options, function () {

Loading…
Cancel
Save