Check for secure mode when getting instance actor key

main
Bob Mottram 2021-09-08 13:07:57 +01:00
parent ac128bb122
commit 26d71b9332
1 changed files with 108 additions and 36 deletions

View File

@ -690,6 +690,8 @@ if args.posts:
proxyType = 'gnunet' proxyType = 'gnunet'
if not args.language: if not args.language:
args.language = 'en' args.language = 'en'
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
getPublicPostsOfPerson(baseDir, nickname, domain, False, True, getPublicPostsOfPerson(baseDir, nickname, domain, False, True,
proxyType, args.port, httpPrefix, debug, proxyType, args.port, httpPrefix, debug,
@ -726,6 +728,8 @@ if args.postDomains:
domainList = [] domainList = []
if not args.language: if not args.language:
args.language = 'en' args.language = 'en'
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
domainList = getPublicPostDomains(None, domainList = getPublicPostDomains(None,
baseDir, nickname, domain, baseDir, nickname, domain,
@ -771,6 +775,8 @@ if args.postDomainsBlocked:
domainList = [] domainList = []
if not args.language: if not args.language:
args.language = 'en' args.language = 'en'
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
domainList = getPublicPostDomainsBlocked(None, domainList = getPublicPostDomainsBlocked(None,
baseDir, nickname, domain, baseDir, nickname, domain,
@ -814,6 +820,8 @@ if args.checkDomains:
maxBlockedDomains = 0 maxBlockedDomains = 0
if not args.language: if not args.language:
args.language = 'en' args.language = 'en'
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
checkDomains(None, checkDomains(None,
baseDir, nickname, domain, baseDir, nickname, domain,
@ -837,6 +845,8 @@ if args.socnet:
args.language = 'en' args.language = 'en'
if not args.domain: if not args.domain:
args.domain = getConfigParam(baseDir, 'domain') args.domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, args.domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, args.domain)
dotGraph = instancesGraph(baseDir, args.socnet, dotGraph = instancesGraph(baseDir, args.socnet,
proxyType, args.port, proxyType, args.port,
@ -868,6 +878,8 @@ if args.postsraw:
proxyType = 'gnunet' proxyType = 'gnunet'
if not args.language: if not args.language:
args.language = 'en' args.language = 'en'
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
getPublicPostsOfPerson(baseDir, nickname, domain, False, False, getPublicPostsOfPerson(baseDir, nickname, domain, False, False,
proxyType, args.port, httpPrefix, debug, proxyType, args.port, httpPrefix, debug,
@ -883,6 +895,8 @@ if args.json:
} }
if not args.domain: if not args.domain:
args.domain = getConfigParam(baseDir, 'domain') args.domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, args.domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, args.domain)
if debug: if debug:
print('baseDir: ' + str(baseDir)) print('baseDir: ' + str(baseDir))
@ -1102,6 +1116,8 @@ if args.approve:
personCache = {} personCache = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
manualApproveFollowRequest(session, baseDir, manualApproveFollowRequest(session, baseDir,
httpPrefix, httpPrefix,
@ -1128,6 +1144,8 @@ if args.deny:
personCache = {} personCache = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
manualDenyFollowRequest(session, baseDir, manualDenyFollowRequest(session, baseDir,
httpPrefix, httpPrefix,
@ -1219,6 +1237,8 @@ if args.message:
isArticle = False isArticle = False
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending post to ' + args.sendto) print('Sending post to ' + args.sendto)
@ -1254,6 +1274,8 @@ if args.announce:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending announce/repeat of ' + args.announce) print('Sending announce/repeat of ' + args.announce)
@ -1296,6 +1318,8 @@ if args.box:
proxyType = 'gnunet' proxyType = 'gnunet'
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
session = createSession(proxyType) session = createSession(proxyType)
@ -1355,6 +1379,8 @@ if args.itemName:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending shared item: ' + args.itemName) print('Sending shared item: ' + args.itemName)
@ -1396,6 +1422,8 @@ if args.undoItemName:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending undo of shared item: ' + args.undoItemName) print('Sending undo of shared item: ' + args.undoItemName)
@ -1456,6 +1484,8 @@ if args.wantedItemName:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending wanted item: ' + args.wantedItemName) print('Sending wanted item: ' + args.wantedItemName)
@ -1497,6 +1527,8 @@ if args.undoWantedItemName:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending undo of wanted item: ' + args.undoWantedItemName) print('Sending undo of wanted item: ' + args.undoWantedItemName)
@ -1529,6 +1561,8 @@ if args.like:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending like of ' + args.like) print('Sending like of ' + args.like)
@ -1560,6 +1594,8 @@ if args.undolike:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending undo like of ' + args.undolike) print('Sending undo like of ' + args.undolike)
@ -1592,6 +1628,8 @@ if args.bookmark:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending bookmark of ' + args.bookmark) print('Sending bookmark of ' + args.bookmark)
@ -1624,6 +1662,8 @@ if args.unbookmark:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending undo bookmark of ' + args.unbookmark) print('Sending undo bookmark of ' + args.unbookmark)
@ -1655,6 +1695,8 @@ if args.delete:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending delete request of ' + args.delete) print('Sending delete request of ' + args.delete)
@ -1698,6 +1740,8 @@ if args.follow:
followHttpPrefix = 'https' followHttpPrefix = 'https'
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
sendFollowRequestViaServer(baseDir, session, sendFollowRequestViaServer(baseDir, session,
@ -1742,6 +1786,8 @@ if args.unfollow:
followHttpPrefix = 'https' followHttpPrefix = 'https'
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
sendUnfollowRequestViaServer(baseDir, session, sendUnfollowRequestViaServer(baseDir, session,
@ -1775,6 +1821,8 @@ if args.followingList:
followHttpPrefix = httpPrefix followHttpPrefix = httpPrefix
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
followingJson = \ followingJson = \
@ -1806,6 +1854,8 @@ if args.followersList:
followHttpPrefix = httpPrefix followHttpPrefix = httpPrefix
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
followersJson = \ followersJson = \
@ -1838,6 +1888,8 @@ if args.followRequestsList:
followHttpPrefix = httpPrefix followHttpPrefix = httpPrefix
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
followRequestsJson = \ followRequestsJson = \
@ -1888,6 +1940,8 @@ if args.migrations:
session = createSession(proxyType) session = createSession(proxyType)
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
ctr = migrateAccounts(baseDir, session, ctr = migrateAccounts(baseDir, session,
httpPrefix, cachedWebfingers, httpPrefix, cachedWebfingers,
@ -1901,6 +1955,8 @@ if args.migrations:
if args.actor: if args.actor:
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
if debug: if debug:
print('baseDir: ' + str(baseDir)) print('baseDir: ' + str(baseDir))
@ -1985,6 +2041,8 @@ if args.followers:
nickname = domain nickname = domain
handle = nickname + '@' + domain handle = nickname + '@' + domain
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
wfRequest = webfingerHandle(session, handle, wfRequest = webfingerHandle(session, handle,
httpPrefix, cachedWebfingers, httpPrefix, cachedWebfingers,
@ -2031,6 +2089,8 @@ if args.followers:
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': 'application/ld+json; profile="' + profileStr + '"'
} }
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
followersList = \ followersList = \
downloadFollowCollection(signingPrivateKeyPem, downloadFollowCollection(signingPrivateKeyPem,
@ -2286,6 +2346,8 @@ if args.skill:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending ' + args.skill + ' skill level ' + print('Sending ' + args.skill + ' skill level ' +
str(args.skillLevelPercent) + ' for ' + nickname) str(args.skillLevelPercent) + ' for ' + nickname)
@ -2319,6 +2381,8 @@ if args.availability:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending availability status of ' + nickname + print('Sending availability status of ' + nickname +
' as ' + args.availability) ' as ' + args.availability)
@ -2431,6 +2495,8 @@ if args.block:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending block of ' + args.block) print('Sending block of ' + args.block)
@ -2461,6 +2527,8 @@ if args.mute:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending mute of ' + args.mute) print('Sending mute of ' + args.mute)
@ -2491,6 +2559,8 @@ if args.unmute:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending undo mute of ' + args.unmute) print('Sending undo mute of ' + args.unmute)
@ -2533,6 +2603,8 @@ if args.unblock:
cachedWebfingers = {} cachedWebfingers = {}
if not domain: if not domain:
domain = getConfigParam(baseDir, 'domain') domain = getConfigParam(baseDir, 'domain')
signingPrivateKeyPem = None
if args.secureMode:
signingPrivateKeyPem = getInstanceActorKey(baseDir, domain) signingPrivateKeyPem = getInstanceActorKey(baseDir, domain)
print('Sending undo block of ' + args.unblock) print('Sending undo block of ' + args.unblock)