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