mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Using a PEM keyfile instead of a DER for the signing key
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ test.py
|
|||||||
*.pyc
|
*.pyc
|
||||||
.cache
|
.cache
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
|
*.pem
|
||||||
@@ -1,6 +1,16 @@
|
|||||||
import ecdsa
|
import ecdsa
|
||||||
|
import os.path
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
|
# Simple tool to generate an ECDSA private key using the secp256k1 curve and save it to signing_key.pem
|
||||||
|
|
||||||
|
FILE_NAME = 'signing_key.pem'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if os.path.exists(FILE_NAME):
|
||||||
|
print("A key with name \"{}\" already exists. Aborting.".format(FILE_NAME))
|
||||||
|
exit(1)
|
||||||
|
|
||||||
sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
|
sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
|
||||||
print(sk.to_der())
|
open(FILE_NAME, 'wb').write(sk.to_pem())
|
||||||
|
print("Saved key \"{}\".".format(FILE_NAME))
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import ecdsa
|
from ecdsa import SigningKey
|
||||||
|
|
||||||
from pisa.logger import Logger
|
from pisa.logger import Logger
|
||||||
from pisa.cleaner import Cleaner
|
from pisa.cleaner import Cleaner
|
||||||
from pisa.conf import EXPIRY_DELTA, MAX_APPOINTMENTS, SIGNING_KEY_DER
|
from pisa.conf import EXPIRY_DELTA, MAX_APPOINTMENTS, SIGNING_KEY_FILE
|
||||||
from pisa.responder import Responder
|
from pisa.responder import Responder
|
||||||
from pisa.block_processor import BlockProcessor
|
from pisa.block_processor import BlockProcessor
|
||||||
from pisa.utils.zmq_subscriber import ZMQHandler
|
from pisa.utils.zmq_subscriber import ZMQHandler
|
||||||
@@ -22,7 +22,11 @@ class Watcher:
|
|||||||
self.max_appointments = max_appointments
|
self.max_appointments = max_appointments
|
||||||
self.zmq_subscriber = None
|
self.zmq_subscriber = None
|
||||||
self.responder = Responder()
|
self.responder = Responder()
|
||||||
self.signing_key = ecdsa.SigningKey.from_der(SIGNING_KEY_DER) if SIGNING_KEY_DER is not None else None
|
if SIGNING_KEY_FILE is not None:
|
||||||
|
self.signing_key = SigningKey.from_pem(open(SIGNING_KEY_FILE).read())
|
||||||
|
else:
|
||||||
|
self.signing_key = None
|
||||||
|
logger.warning("No signing key provided. Appointments will not be signed.")
|
||||||
|
|
||||||
def add_appointment(self, appointment):
|
def add_appointment(self, appointment):
|
||||||
# Rationale:
|
# Rationale:
|
||||||
|
|||||||
Reference in New Issue
Block a user