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_ca——PEM cert string
get_crl——Base64 CRL
generate_crl——Base64 CRL
generatecnprofile, sans, local{dn, certificate, serial}
signcsrprofile{certificate, serial}
registerseed, cnprofile, sans{dn, certificate, serial}
renewdnduration{certificate, serial}
revokednreasonboolean
unrevokedn—boolean
deletedn—boolean
viewdn—certificate details dict
ocsp_checkcert—OCSP status dict

Profile tasks

TaskRequired paramsResponse
list_profiles—list of profile names
get_profileprofileprofile details dict

Admin tasks

TaskRequired paramsResponse
list_admins—list of admin DNs
add_admindnboolean
remove_admindnboolean
list_nodes—list of node dicts
get_nodecnnode details dict

ACME sync tasks

TaskRequired paramsOptional paramsResponse
acme_sync_accountaccount_id, jwkcontact, status, created_atboolean
acme_get_accountaccount_id—account dict
acme_list_accounts——list of account dicts
acme_deactivate_accountaccount_id—boolean
acme_sync_orderorder_id, account_id, identifiersstatus, not_before, not_afterboolean
acme_get_orderorder_id—order dict
acme_list_ordersaccount_id—list of order dicts
acme_sync_authorizationauth_id, order_id, identifier_type, identifier_valuestatusboolean
acme_get_authorizationauth_id—authorization dict
acme_deactivate_authorizationauth_id—boolean
acme_issue_certificateorder_id, csrprofile{certificate, serial}
acme_get_certificatecert_id—certificate 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