Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ function parse (profile, graph, uri, mimeType, callback) {
$rdf.parse(profile, graph, uri, mimeType)
return callback(null, graph)
} catch(e) {
return callback('Cound not load/parse profile data')
return callback(new Error('Could not load/parse profile data: ' + e))
}
}
26 changes: 25 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,31 @@ describe('WebID', function () {
'',
'text/html',
function (err, result) {
expect(err).to.equal('Cound not load/parse profile data')
expect(err.message).to.include('Could not load/parse profile data')
done()
})
})

it('should succeed on text/turtle', function (done) {
tls.verifyKey(
validCert,
'https://test_nicola.databox.me/profile/card#me',
'',
'text/turtle',
function (err, result) {
expect(err.message).to.not.include('Could not load/parse profile data')
done()
})
})

it('should succeed on text/turtle; charset=utf-8', function (done) {
tls.verifyKey(
validCert,
'https://test_nicola.databox.me/profile/card#me',
'',
'text/turtle; charset=utf-8',
function (err, result) {
expect(err.message).to.not.include('Could not load/parse profile data')
done()
})
})
Expand Down
7 changes: 4 additions & 3 deletions tls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ function verify (certificate, callback) {

// Get first URI
var uri = uris.shift()
get(uri, function (err, body, headers) {
get(uri, function (err, body, contentType) {
if (err) {
return callback(err)
}

// Verify Key
verifyKey(certificate, uri, body, headers, function (err, success) {
verifyKey(certificate, uri, body, contentType, function (err, success) {
return callback(err, uri)
})
})
Expand All @@ -54,7 +54,7 @@ function getUris (certificate) {
return uris
}

function verifyKey (certificate, uri, profile, mimeType, callback) {
function verifyKey (certificate, uri, profile, contentType, callback) {
var graph = new Graph()
var found = false

Expand All @@ -66,6 +66,7 @@ function verifyKey (certificate, uri, profile, mimeType, callback) {
return callback(new Error('Missing exponent value in client certificate'))
}

var mimeType = contentType.replace(/;.*/, '')
parse(profile, graph, uri, mimeType, function (err) {
if (err) {
return callback(err)
Expand Down