Skip to content

Commit 5ebacc3

Browse files
author
nicola
committed
wrap spkac in the buffer
1 parent be9c8d8 commit 5ebacc3

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎lib/handlers/error.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
var fs = require('fs');
55

66
function errorPageHandler(err, req, res, next) {
7+
console.log(err, err.stack)
78
var ldp = req.app.locals.ldp;
89

910
// If the user specifies this function

‎lib/identity-provider.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,17 @@ IdentityProvider.prototype.get = function (req, res, next) {
306306

307307
IdentityProvider.prototype.newCert = function (req, res, next) {
308308
var self = this
309-
debug('Requesting new cert for ' + options.webid)
310309

311310
var options = req.body
312-
if (!options.spkac || !options.webid) {
311+
if (!options || !options.spkac || !options.webid) {
313312
debug('Request for certificate not valid')
314313
var err = new Error('Request for certificate not valid')
315314
err.status = 500
316315
return next(err)
317316
}
318317

318+
debug('Requesting new cert for ' + options.webid)
319+
319320
if (req.session.userId !== options.webid) {
320321
debug('user is not logged in: ' + req.session.userId + ' is not ' + options.webid)
321322
var error = new Error('You are not logged in, so you can\'t create a certificate')
@@ -327,7 +328,7 @@ IdentityProvider.prototype.newCert = function (req, res, next) {
327328

328329
// Get a new cert
329330
webid('tls').generate({
330-
spkac: options.spkac,
331+
spkac: new Buffer(options.spkac),
331332
agent: options.webid
332333
}, function (err, cert) {
333334
if (err) {
@@ -380,7 +381,7 @@ IdentityProvider.prototype.getGraph = function (uri, callback) {
380381
data += chunk
381382
})
382383
.on('end', function () {
383-
parse(data, function (err, card) {
384+
parse(data, null, 'text/turtle', function (err, card) {
384385
if (err) {
385386
debug('WebId can\'t be parsed')
386387
var invalid = new Error('You have an invalid WebID card')
@@ -416,7 +417,7 @@ IdentityProvider.prototype.post = function (req, res, next) {
416417
function (callback) {
417418
if (options.spkac && options.spkac.length > 0) {
418419
webid('tls').generate({
419-
spkac: options.spkac,
420+
spkac: new Buffer(options.spkac),
420421
agent: agent // TODO generate agent
421422
}, callback)
422423
} else {

0 commit comments

Comments
 (0)