@@ -306,16 +306,17 @@ IdentityProvider.prototype.get = function (req, res, next) {
306306
307307IdentityProvider . 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