Last active
October 11, 2021 15:30
-
-
Save abeluck/bb7b28fa75872212839e6fb3f07000d3 to your computer and use it in GitHub Desktop.
Generate a synapse signing key from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a signing key for synapse from the command line | |
# | |
# Usage: python3 generate-signing-key.py | |
# | |
# You must have the signedjson package installed: | |
# apt install python3-signedjson | |
# pip3 install signedjson | |
# | |
# Author: Abel Luck <[email protected]> | |
# Created: April 25 2019 | |
# Updated: October 11 2021 | |
import random | |
import string | |
import io | |
from signedjson.key import generate_signing_key, write_signing_keys | |
def random_string(length): | |
return ''.join(random.choice(string.ascii_letters) for _ in range(length)) | |
key_id = "a_" + random_string(4) | |
with io.StringIO() as f: | |
write_signing_keys(f, (generate_signing_key(key_id),),) | |
f.seek(0) | |
print(f.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signedjson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment