diff --git a/src/server/openpgpProfiles.js b/src/server/openpgpProfiles.js index 2192bbe..c0086af 100644 --- a/src/server/openpgpProfiles.js +++ b/src/server/openpgpProfiles.js @@ -102,7 +102,16 @@ const fetchWKD = (id) => { reject(new Error('No public keys could be read from the data fetched using WKD')) } - profile = await doipjs.openpgp.parsePublicKey(publicKey) + try { + profile = await doipjs.openpgp.parsePublicKey(publicKey) + } catch (error) { + profile = null + } + + if (!profile) { + reject(new Error('No public keys could be fetched using WKD')) + return + } profile.publicKey.fetch.method = 'wkd' profile.publicKey.fetch.query = id profile.publicKey.fetch.resolvedUrl = fetchURL