bugfix: options.certificate is optional #5

Closed
coolaj86 wants to merge 1 commits from kid-fix into initial-release
1 changed files with 3 additions and 3 deletions

View File

@ -17,7 +17,7 @@ module.exports.create = function (config={}) {
else {
// This library expects config.db to resolve the db object. We'll ensure
// that this is the case with the provided db, as it was with the baked-in
// db.
// db.
config.db = Promise.resolve(config.db);
}
@ -108,7 +108,7 @@ module.exports.create = function (config={}) {
return db.Keypair.findOne({
where: {
// using xid because id is reserved by sequelize
xid: opts.certificate.kid || opts.certificate.id || opts.subject
xid: (opts.certificate && (opts.certificate.kid || opts.certificate.id)) || opts.subject
}
});
}).then(function (record) {
@ -131,7 +131,7 @@ module.exports.create = function (config={}) {
return db.Keypair.findOrCreate({
where: {
// using xid because id is reserved by sequelize
xid: opts.certificate.kid || opts.certificate.id || opts.subject
xid: (opts.certificate && (opts.certificate.kid || opts.certificate.id)) || opts.subject
}
});
}).then(function ([record,created]) {