Check continuity of public key

main2
Bob Mottram 2019-09-14 20:06:08 +01:00
parent e18fe78b9c
commit 743221b901
1 changed files with 13 additions and 0 deletions

View File

@ -74,6 +74,19 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata
sessionHeaders = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'} sessionHeaders = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'}
personJson = getJson(session,actor,sessionHeaders,None,__version__,httpPrefix,None) personJson = getJson(session,actor,sessionHeaders,None,__version__,httpPrefix,None)
if personJson: if personJson:
if not personJson.get('id'):
return None
if not personJson.get('publicKey'):
return None
if not personJson['publicKey'].get('publicKeyPem'):
return None
if personJson['id']!=actor:
return None
if not personCache.get(actor):
return None
if personCache[actor]['actor']['publicKey']['publicKeyPem']!=personJson['publicKey']['publicKeyPem']:
print("ERROR: public keys don't match when downloading actor for "+actor)
return None
storePersonInCache(baseDir,actor,personJson,personCache) storePersonInCache(baseDir,actor,personJson,personCache)
return getPersonAvatarUrl(baseDir,actor,personCache) return getPersonAvatarUrl(baseDir,actor,personCache)
return None return None