Permalink
Browse files

upgrade data formats

  • Loading branch information...
1 parent 61d4fc9 commit 67e54de3bb032d7839449f6f1834d0b819b9d7b7 @benadida benadida committed Jul 21, 2012
View
@@ -29,7 +29,7 @@ function certify(hostname, email, publicKey, expiration, cb) {
if (expiration == null)
return cb("expiration cannot be null");
- cert.sign(publicKey, {email: email},
+ cert.sign({publicKey: publicKey, principal: {email: email}},
{issuer: hostname, issuedAt: new Date(), expiresAt: expiration},
null,
secret_key, cb);
View
@@ -115,5 +115,7 @@ exports.publicKeyCreationDate = function(name, dir) {
};
exports.loadPublicKey = function(name, dir) {
- return jwcrypto.loadPublicKey(JSON.stringify(readAndParseCert(name, dir)['public-key']));
+ var parsedCert = readAndParseCert(name, dir);
+ var pkString = parsedCert['public-key'] || parsedCert.publicKey;
+ return jwcrypto.loadPublicKey(JSON.stringify(pkString));
};
View
@@ -18,7 +18,7 @@
"express": "2.5.0",
"gobbledygook": "0.0.3",
"mustache": "0.3.1-dev",
- "jwcrypto": "0.3.2",
+ "jwcrypto": "https://github.com/mozilla/jwcrypto/tarball/2012-07-new-data-formats",
"mysql": "0.9.5",
"node-statsd": "https://github.com/downloads/lloyd/node-statsd/0509f85.tgz",
"nodemailer": "0.1.24",
@@ -90,7 +90,9 @@ exampleServer.post("/api/cert_key", function (req, res) {
var expiration = new Date();
var pubkey = jwcrypto.loadPublicKeyFromObject(req.body.pubkey);
expiration.setTime(new Date().valueOf() + req.body.duration * 1000);
- jwcrypto.cert.sign(pubkey, {email: user + "@" + domain}, {issuer: domain, expiresAt: expiration, issuedAt: new Date()}, {}, _privKey, function(err, cert) {
+ jwcrypto.cert.sign({publicKey: pubkey, principal: {email: user + "@" + domain}},
+ {issuer: domain, expiresAt: expiration, issuedAt: new Date()},
+ {}, _privKey, function(err, cert) {
res.json({ cert: cert });
});
});
@@ -68,7 +68,7 @@ suite.addBatch({
var expiration = new Date();
expiration.setTime(new Date().valueOf() + 60 * 60 * 1000);
- jwcrypto.cert.sign(g_keypair.publicKey, {email: TEST_EMAIL}, {issuer: TEST_DOMAIN, expiresAt: expiration, issuedAt: new Date()}, null, g_privKey, this.callback);
+ jwcrypto.cert.sign({publicKey: g_keypair.publicKey, principal: {email: TEST_EMAIL}}, {issuer: TEST_DOMAIN, expiresAt: expiration, issuedAt: new Date()}, null, g_privKey, this.callback);
},
"works swimmingly": function(err, cert) {
assert.isString(cert);
@@ -88,7 +88,7 @@ suite.addBatch({
// sign this innerkeypair with the key from g_cert (g_keypair)
jwcrypto.cert.sign(
- innerKeypair.publicKey, {email: OTHER_EMAIL},
+ {publicKey: innerKeypair.publicKey, principal: {email: OTHER_EMAIL}},
{issuedAt: new Date(), expiresAt: expirationDate},
{}, primaryUser._keyPair.secretKey,
function(err, innerCert) {
@@ -193,7 +193,7 @@ suite.addBatch({
suite.addBatch({
"sign a cert": {
topic: function() {
- jwcrypto.cert.sign(userKeypair.publicKey, {email: EMAIL},
+ jwcrypto.cert.sign({publicKey: userKeypair.publicKey, principal: {email: EMAIL}},
{issuedAt: now, issuer: ISSUER, expiresAt: in_a_minute},
{},
domainKeypair.secretKey, this.callback);
@@ -30,7 +30,7 @@ User.prototype.setup = function(cb) {
var expiration = new Date();
expiration.setTime(new Date().valueOf() + 60 * 60 * 1000);
- jwcrypto.cert.sign(self._keyPair.publicKey, {email: self.options.email},
+ jwcrypto.cert.sign({publicKey: self._keyPair.publicKey, principal: {email: self.options.email}},
{expiresAt: expiration, issuer: self.options.domain, issuedAt: new Date()},
{}, self.options.privKey || g_privKey, function(err, signedCert) {
if (err) return cb(err);
@@ -328,7 +328,7 @@ suite.addBatch({
var expiration = new Date();
expiration.setTime(new Date().valueOf() + 60 * 60 * 1000);
- jwcrypto.cert.sign(g_keypair.publicKey, {email: TEST_EMAIL},
+ jwcrypto.cert.sign({publicKey: g_keypair.publicKey, principal: {email: TEST_EMAIL}},
{expiresAt: expiration, issuedAt: new Date(), issuer: TEST_DOMAIN},
null, g_privKey, this.callback);
},
@@ -536,7 +536,7 @@ suite.addBatch({
"certify the user key": {
topic: function() {
var expiration = new Date(new Date().getTime() + (1000 * 60 * 60 * 6));
- jwcrypto.cert.sign(newClientKeypair.publicKey, {email: TEST_EMAIL},
+ jwcrypto.cert.sign({publicKey: newClientKeypair.publicKey, principal: {email: TEST_EMAIL}},
{issuedAt: new Date(), issuer: "127.0.0.1",
expiresAt: expiration},
{}, fakeDomainKeypair.secretKey, this.callback);
@@ -786,7 +786,7 @@ suite.addBatch({
"certify the user key for other issuer": {
topic: function() {
var expiration = new Date(new Date().getTime() + (1000 * 60 * 60 * 6));
- jwcrypto.cert.sign(newClientKeypair.publicKey, {email: TEST_EMAIL},
+ jwcrypto.cert.sign({publicKey: newClientKeypair.publicKey, principal: {email: TEST_EMAIL}},
{issuedAt: new Date(), issuer: "no.such.domain",
expiresAt: expiration},
{}, fakeDomainKeypair.secretKey, this.callback);
@@ -856,7 +856,7 @@ suite.addBatch({
path.join(__dirname, '..', 'example', 'primary', 'sample.privatekey')));
var expiration = new Date(new Date().getTime() + (1000 * 60 * 60 * 6));
- jwcrypto.cert.sign(newClientKeypair.publicKey, {email: TEST_EMAIL},
+ jwcrypto.cert.sign({publicKey: newClientKeypair.publicKey, principal: {email: TEST_EMAIL}},
{issuedAt: new Date(), issuer: "example.domain",
expiresAt: expiration},
{}, secretKey, this.callback);
@@ -914,7 +914,7 @@ suite.addBatch({
path.join(__dirname, '..', 'example', 'primary', 'sample.privatekey')));
var expiration = new Date(new Date().getTime() + (1000 * 60 * 60 * 6));
- jwcrypto.cert.sign(newClientKeypair.publicKey, {email: "foo@example.domain"},
+ jwcrypto.cert.sign({publicKey: newClientKeypair.publicKey, principal: {email: "foo@example.domain"}},
{issuedAt: new Date(), issuer: "example.domain",
expiresAt: expiration},
{}, secretKey, this.callback);
@@ -983,7 +983,7 @@ suite.addBatch({
// sign this innerkeypair with the key from g_cert (g_keypair)
jwcrypto.cert.sign(
- innerKeypair.publicKey, {email: OTHER_EMAIL},
+ {publicKey: innerKeypair.publicKey, principal: {email: OTHER_EMAIL}},
{issuedAt: new Date(), expiresAt: expirationDate},
{}, g_keypair.secretKey,
function(err, innerCert) {

0 comments on commit 67e54de

Please sign in to comment.