View on GitHub tezio logo

Tezio Signer

Tezio Signer is a Python Flask application for relaying Tezos signing requests from Octez to a Tezio HSM. Signing requests are validated against a security and signing policy then forwarded to a Tezio HSM connected via USB using the Tezio HSM API.

Introduction

Tezio Signer is located in the signer directory of the repository. The directory contains the app, tezio_signer.py, and a Python class to handle communication with the Tezio HSM, tezio.ph. The security and signing policies for the various keys provisioned on the Tezio HSM are declared in the config.yaml file.

Security and Signing Policy

The security policy defined in config.yaml

Running Tezio Signer Using Gunicorn

Flask’s built in WSGI server is only meant for testing. Therefore, it is advisable to run Tezio Signer using a production-ready WSGI server like Gunicorn.

Install Gunicorn

sudo apt-get update
sudo apt-get install gunicorn

Run the App

cd [PATH_TO_TEZIO_REPO]/signer
chmod u+x tezio_signer.py
gunicorn --bind 127:0.0.1:[PORT] tezio_signer:app

Running Tezio Signer as a Persistent Daemon

There are several options to accomplish this. One possibility is to run as a background process using Supervisor.

Install Supervisor

sudo apt-get update
sudo apt-get install supervisor

Check Supervisor Status

sudo systemctl status supervisor

Create a Configuration File for Tezio Signer

cd /etc/supervisor/conf.d
sudo nano tezio-signer.conf

Compose the Configuration File’s Content

[program:tezio_signer_flask_app_via_gunicorn]
user=[USER_NAME]
directory=[PATH_TO_TEZIO_REPO]/signer
command=gunicorn --bind 127.0.0.1:[PORT] tezio_signer:app
autostart=true
autorestart=true
stdout_logfile=[PATH_TO_TEZIO_REPO]/signer/tezio_signer_out.log
stderr_logfile=[PATH_TO_TEZIO_REPO]/tezio_signer.log

Update Supervisor

sudo supervisorctl reread
sudo supervisorctl update

Check Daemon Status

sudo supvervisorctl status

Requirements

pip install flask, base58, pyserial