Skip to content

[feature:gsoc26] Expose certificate data as template variables #1360

@stktyagi

Description

@stktyagi

Is your feature request related to a problem? Please describe.
Once a standalone certificate is generated, its payload, PEM and Private Key, is stored securely in the database. However, this payload is currently inaccessible to the OpenWISP configuration engine, meaning administrators cannot actually deploy the certificates into the device's configuration files.

Describe the solution you'd like
I will extend the configuration variable context to inject certificate payloads directly into the templating engine:

  1. Context Generation: implement a get_cert_context() method extending Config.get_context(). This will iterate over the devicecertificate_set and build an Ordered Dictionary of the active certificates.

  2. UUID Namespacing: to prevent variable collisions when multiple cert templates are assigned to a single device, generate predictable, UUID-namespaced variables. Specifically:

    • cert_{template_pk_hex}_pem: the generated certificate.
    • cert_{template_pk_hex}_key: the private key.
    • cert_{template_pk_hex}_uuid: the object UUID.
  3. Template Usage: administrators will then be able to reference these variables dynamically inside standard OpenWISP templates using the {{ variable_name }} syntax.

Requirement from the GSoC proposal

The proposal requires exposing the certificate PEM, private key PEM, and certificate UUID in Config.get_context() using a UUID-based namespace to avoid conflicts.

Decision to keep open

The proposal example uses names like cert_<template_uuid>_pem, while this issue currently uses cert_{template_pk_hex}_pem. The exact UUID-based namespace should be confirmed during implementation and documented before merging.

Measurable outcomes: 5
Implementation points: 4, 5

Metadata

Metadata

Assignees

Labels

enhancementgsocPart of a Google Summer of Code project
No fields configured for Feature.

Projects

Status

ToDo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions