Api

ZMQ Protocol Reference

Complete reference for the ZMQ REQ/REP protocol between uPKI CA and RA/CLI.

ZMQ Protocol Reference

The uPKI CA exposes two ZMQ REP sockets. Clients communicate using ZMQ REQ sockets with JSON payloads.

Transport

PropertyValue
ProtocolZMQ REQ/REP (zmq.REP)
SerializationJSON strings (UTF-8)
Timeout5000 ms
Port 5000CA operations (all registered nodes)
Port 5001RA registration (first-boot only, clear mode)

Message format

Request

{
  "TASK": "<task_name>",
  "params": {
    "<param>": "<value>"
  }
}

Success response

{
  "EVENT": "ANSWER",
  "DATA": <result>
}

Error response

{
  "EVENT": "UPKI ERROR",
  "MSG": "<error_message>"
}

Port 5000 — CA operations

Certificate tasks

TaskRequired paramsOptional paramsResponse
get_caPEM cert string
get_crlBase64 CRL
generate_crlBase64 CRL
generatecnprofile, sans, local{dn, certificate, serial}
signcsrprofile{certificate, serial}
registerseed, cnprofile, sans{dn, certificate, serial}
renewdnduration{certificate, serial}
revokednreasonboolean
unrevokednboolean
deletednboolean
viewdncertificate details dict
ocsp_checkcertOCSP status dict

Profile tasks

TaskRequired paramsResponse
list_profileslist of profile names
get_profileprofileprofile details dict

Admin tasks

TaskRequired paramsResponse
list_adminslist of admin DNs
add_admindnboolean
remove_admindnboolean
list_nodeslist of node dicts
get_nodecnnode details dict

ACME sync tasks

TaskRequired paramsOptional paramsResponse
acme_sync_accountaccount_id, jwkcontact, status, created_atboolean
acme_get_accountaccount_idaccount dict
acme_list_accountslist of account dicts
acme_deactivate_accountaccount_idboolean
acme_sync_orderorder_id, account_id, identifiersstatus, not_before, not_afterboolean
acme_get_orderorder_idorder dict
acme_list_ordersaccount_idlist of order dicts
acme_sync_authorizationauth_id, order_id, identifier_type, identifier_valuestatusboolean
acme_get_authorizationauth_idauthorization dict
acme_deactivate_authorizationauth_idboolean
acme_issue_certificateorder_id, csrprofile{certificate, serial}
acme_get_certificatecert_idcertificate dict
acme_revoke_certificatecertificatereasonboolean

Port 5001 — RA registration

Registration is a one-shot operation. The RA presents its seed and CN; the CA issues a certificate.

{
  "TASK": "register",
  "params": {
    "seed": "registration-seed",
    "cn": "upki-ra",
    "profile": "ra",
    "sans": [{ "type": "DNS", "value": "upki-ra" }]
  }
}

Examples

Get the CA certificate

import zmq
import json

ctx = zmq.Context()
sock = ctx.socket(zmq.REQ)
sock.connect("tcp://127.0.0.1:5000")
sock.send_string(json.dumps({"TASK": "get_ca", "params": {}}))
reply = json.loads(sock.recv_string())
ca_pem = reply["DATA"]

Issue a server certificate

sock.send_string(json.dumps({
    "TASK": "generate",
    "params": {
        "cn": "api.example.internal",
        "profile": "server",
        "sans": [{"type": "DNS", "value": "api.example.internal"}]
    }
}))
result = json.loads(sock.recv_string())
# result["DATA"] = {"dn": "...", "certificate": "...", "serial": "..."}

Revoke a certificate

sock.send_string(json.dumps({
    "TASK": "revoke",
    "params": {
        "dn": "/CN=api.example.internal",
        "reason": "keyCompromise"
    }
}))
result = json.loads(sock.recv_string())
# result["DATA"] = True
Copyright © 2026