Skip to content

Commit

Permalink
Raise an exception if private key is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed Nov 5, 2024
1 parent 449dace commit cfc3e28
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/organisations/subscriptions/licensing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
logger: logging.Logger = logging.getLogger(name=__name__)


class PrivateKeyMissingError(RuntimeError):
pass


def sign_licence(licence: str) -> str:
message = licence.encode("utf-8")

if not settings.SUBSCRIPTION_LICENCE_PRIVATE_KEY:
raise PrivateKeyMissingError("Private key is missing")

# Load the private key from PEM
private_key = serialization.load_pem_private_key(
settings.SUBSCRIPTION_LICENCE_PRIVATE_KEY.encode("utf-8"), password=None
Expand Down

0 comments on commit cfc3e28

Please sign in to comment.