| 6 | const SPARQL_QUERY = 'PREFIX cert: <http://www.w3.org/ns/auth/cert#> SELECT ?webid ?m ?e WHERE { ?webid cert:key ?key . ?key cert:modulus ?m . ?key cert:exponent ?e . }' |
| 7 | |
| 8 | export function verify (certificateObj, callback) { |
| 9 | if (!certificateObj) { |
| 10 | return callback(new Error('No certificate given')) |
| 11 | } |
| 12 | const uris = getUris(certificateObj) |
| 13 | if (uris.length === 0) { |
| 14 | return callback(new Error('Empty Subject Alternative Name field in certificate')) |
| 15 | } |
| 16 | const uri = uris.shift() |
| 17 | get(uri, function (err, body, contentType) { |
| 18 | if (err) { |
| 19 | return callback(err) |
| 20 | } |
| 21 | verifyKey(certificateObj, uri, body, contentType, function (err, success) { |
| 22 | return callback(err, uri) |
| 23 | }) |
| 24 | }) |
| 25 | } |
| 26 | |
| 27 | function getUris (certificateObj) { |
| 28 | const uris = [] |