Browse Source

added test case for foaf+ssl client certificate

Niclas Hoyer 14 years ago
committed by koichik
parent
commit
b7e36f8584
  1. 25
      test/fixtures/foafssl.crt
  2. 32
      test/fixtures/foafssl.key
  3. 85
      test/simple/test-https-foafssl.js

25
test/fixtures/foafssl.crt

@ -0,0 +1,25 @@
Bag Attributes
friendlyName: Me's Not a Certification Authority ID
localKeyID: 98 CC 02 91 83 8D 14 4A 60 40 B7 11 E8 EF A9 01 4B D7 16 8A
subject=/O=FOAF+SSL/OU=The Community Of Self Signers/UID=http://example.com/#me/CN=Me
issuer=/O=FOAF+SSL/OU=The Community of Self Signers/CN=Not a Certification Authority
-----BEGIN CERTIFICATE-----
MIIDVDCCAr2gAwIBAgIQRLIhwZ2N3ciEdpWb6kPmPzANBgkqhkiG9w0BAQUFADBj
MREwDwYDVQQKDAhGT0FGK1NTTDEmMCQGA1UECwwdVGhlIENvbW11bml0eSBvZiBT
ZWxmIFNpZ25lcnMxJjAkBgNVBAMMHU5vdCBhIENlcnRpZmljYXRpb24gQXV0aG9y
aXR5MB4XDTExMDgzMDE3MzIwNFoXDTEyMDgyMDE5MzIwNFowcDERMA8GA1UECgwI
Rk9BRitTU0wxJjAkBgNVBAsMHVRoZSBDb21tdW5pdHkgT2YgU2VsZiBTaWduZXJz
MSYwJAYKCZImiZPyLGQBAQwWaHR0cDovL2V4YW1wbGUuY29tLyNtZTELMAkGA1UE
AwwCTWUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCm9EqcJXkUMSFP
XIevngQBd6i7iayAP34Ju8OlUZ80nNm5xAvkNtCqgjqUFH4myJJIraK+PdTTTowo
lkaUsgR9IXtPEpk3Hqk6g8iauUQHJBMeZfKwFh3pVgzenBNFVVKy9Jzw+wDY13Uy
MkkT9vgP8p0KEx0p2wav+L4ZG3kg3C2uHCbqgqR4R6EDke879qq7PMQP+CEAsDpP
D/GAknjk3f2n3pVO1W3HrZpH7rw313GjZvxgpby3I3O+wYBkmz76DpCScHIQtBuQ
Ayuxi8kfIEbr2vEZH0pOJtcYecTHhnti/NUI6M5m6C0SinHpFYCfz0To3ndAZ/He
XXC5wDaHAgMBAAGjeDB2MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgLsMBEG
CWCGSAGG+EIBAQQEAwIFoDAdBgNVHQ4EFgQU3gJIUFpe8rKklsjEdsxlaT6rZhow
JAYDVR0RAQH/BBowGIYWaHR0cDovL2V4YW1wbGUuY29tLyNtZTANBgkqhkiG9w0B
AQUFAAOBgQBLhwWbYMdeSkVZ4biVUle+XHP4Gv8V9WSfldvgn1PntS1lpVR46Exl
AkLO1SrnN5WHeAjv6VNb3KmTF+QhLt/4a1l9CEEeZSg5ml5aeXE+veobgypDoam+
NKYAeIW9Wx+HcgBL4leIX3WiCKu/eal+a5ro18LQ8hkZqryHeVESIw==
-----END CERTIFICATE-----

32
test/fixtures/foafssl.key

@ -0,0 +1,32 @@
Bag Attributes
friendlyName: Me's Not a Certification Authority ID
localKeyID: 98 CC 02 91 83 8D 14 4A 60 40 B7 11 E8 EF A9 01 4B D7 16 8A
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCm9EqcJXkUMSFP
XIevngQBd6i7iayAP34Ju8OlUZ80nNm5xAvkNtCqgjqUFH4myJJIraK+PdTTTowo
lkaUsgR9IXtPEpk3Hqk6g8iauUQHJBMeZfKwFh3pVgzenBNFVVKy9Jzw+wDY13Uy
MkkT9vgP8p0KEx0p2wav+L4ZG3kg3C2uHCbqgqR4R6EDke879qq7PMQP+CEAsDpP
D/GAknjk3f2n3pVO1W3HrZpH7rw313GjZvxgpby3I3O+wYBkmz76DpCScHIQtBuQ
Ayuxi8kfIEbr2vEZH0pOJtcYecTHhnti/NUI6M5m6C0SinHpFYCfz0To3ndAZ/He
XXC5wDaHAgMBAAECggEAEhwrv7Zc5PDTYS1zVnx4iMQ3HGi5uouom1uvxE4PT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uQIxGJYHTHn6CZhqrX8UbxVnS909ES+17kdLZVP
egvaxn1mtfZInnH64PiQDQrsNnbP4Zg8yvLvIcEVIPqnSQ5QrhdR29tjYuDwUIKM
4BMR2yfkFp6URRX7ZD1UQsduww==
-----END PRIVATE KEY-----

85
test/simple/test-https-foafssl.js

@ -0,0 +1,85 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
if (!process.versions.openssl) {
console.error("Skipping because node compiled without OpenSSL.");
process.exit(0);
}
var common = require('../common');
var assert = require('assert');
var join = require('path').join;
var fs = require('fs');
var exec = require('child_process').exec;
var https = require('https');
var options = {
key: fs.readFileSync(common.fixturesDir + '/agent.key'),
cert: fs.readFileSync(common.fixturesDir + '/agent.crt'),
requestCert: true
};
var reqCount = 0;
var body = 'hello world\n';
var cert;
var subjectaltname;
var modulus;
var exponent;
var server = https.createServer(options, function (req, res) {
reqCount++;
console.log("got request");
cert = req.connection.getPeerCertificate();
subjectaltname = cert.subjectaltname;
modulus = cert.modulus;
exponent = cert.exponent;
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(body);
})
server.listen(common.PORT, function () {
var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/';
cmd += ' --cert '+join(common.fixturesDir, 'foafssl.crt');
cmd += ' --key '+join(common.fixturesDir, 'foafssl.key');
console.error("executing %j", cmd);
exec(cmd, function(err, stdout, stderr) {
if (err) throw err;
common.error(common.inspect(stdout));
assert.equal(body, stdout);
server.close();
});
});
process.on('exit', function () {
assert.equal(subjectaltname, 'URI:http://example.com/#me');
assert.equal(modulus, 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC\
3A5519F349CD9B9C40BE436D0AA823A94147E26C89248ADA2BE3DD4D34E8C28964694B2047D217\
B4F1299371EA93A83C89AB9440724131E65F2B0161DE9560CDE9C13455552B2F49CF0FB00D8D77\
532324913F6F80FF29D0A131D29DB06AFF8BE191B7920D');
assert.equal(exponent, '10001');
});
Loading…
Cancel
Save