# openvpn/easy-rsa architecture

> Architecture diagram of the GitHub repository openvpn/easy-rsa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openvpn/easy-rsa
- Repository: https://github.com/openvpn/easy-rsa

## Overview

##### Project Type and Purpose
- This is an open-source command-line utility (“easy-rsa”) for building and managing a Public Key Infrastructure (PKI) Certificate Authority.
- It orchestrates OpenSSL to generate root/intermediate CAs, certificates, and revocation lists via shell scripts and configuration templates.

##### High-Level Components
a. Core CLI Engine (easyrsa3/)
- easyrsa (POSIX shell script entry point)
- openssl-easyrsa.cnf (base OpenSSL configuration)
- vars.example (environment variable template)
- x509-types/ (templates for different certificate profiles)
b. External Utility
- OpenSSL binary (invoked by the CLI engine for crypto operations)
c. Build & Packaging
- build/ (Linux/macOS build scripts & build-dist.sh)
- distro/windows/ (Windows-packaged binaries, shell environment, licenses)
d. CI/CD Pipeline
- .github/workflows/action.yml (GitHub Actions build, test, and release jobs)
e. Documentation & Tests
- doc/ (Markdown documentation, tutorials, contribution guidelines)
- README.quickstart.md, README.md, ChangeLog, KNOWN_ISSUES
- op-test.sh, wop-test.sh/.bat (smoke tests)

##### Relationships and Interactions
- User invokes the easyrsa CLI script →
- Reads vars (from vars.example or user override)
- Loads profile templates from x509-types/
- Calls the OpenSSL binary with generated config (openssl-easyrsa.cnf)
- Reads/writes to a file-system directory tree (PKI folder structure)
- Build system:
- Local or CI (GitHub Actions) triggers build-dist.sh →
◦ Packages the easyrsa script + supporting files into tarballs or zip archives
◦ Prepares Windows “distro/windows” ZIP with UNIX utilities and OpenSSL EXEs
- CI/CD:
- On git push or tag → runs tests (op-test.sh, wop-test.sh/bat) → uploads artifacts/releases

##### Architectural Patterns & Principles
- Modular Shell Orchestration: separation of script logic (easyrsa) and configuration/templates (cnf + x509-types).
- POSIX Compliance: scripts aim to run on any POSIX shell; Windows support provided via bundled utilities.
- Clear separation of concerns:
- Execution (CLI)
- Configuration (vars, profiles)
- Cryptography (external OpenSSL)
- Distribution (build scripts + packaging)
- Documentation & testing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    UserShell["User Shell / CLI"]:::runtime

    %% Core CLI Engine
    subgraph "Core CLI Engine"
        direction TB
        EasyrsaScript["easyrsa Script"]:::runtime
        ConfigTemplates["Configuration & Templates"]:::config
        subgraph "Templates Directory"
            direction TB
            X509Types["x509-types/"]:::config
        end
        VarsExample["vars.example"]:::config
        OpenSslCnf["openssl-easyrsa.cnf"]:::config
    end

    %% External Utility
    OpenSSLBin["OpenSSL Binary"]:::runtime

    %% Data store
    PKIDir["PKI Directory (certs, keys, crl)"]:::data

    %% Build & Packaging
    subgraph "Build & Packaging" 
        direction TB
        BuildScript["build-dist.sh & packaging"]:::build
        subgraph "Windows Distro Bundle"
            direction TB
            WindowsBundle["distro/windows"]:::build
        end
        LinuxTarball["Linux Tarball"]:::build
    end

    %% CI/CD Pipeline
    GitHubCI["GitHub Actions CI"]:::build

    %% Flows
    UserShell -->|"invokes"| EasyrsaScript
    EasyrsaScript -->|"loads"| ConfigTemplates
    EasyrsaScript -->|"executes crypto operations"| OpenSSLBin
    OpenSSLBin -->|"reads/writes certs & keys"| PKIDir
    GitHubCI -->|"runs"| BuildScript
    BuildScript -->|"packages"| WindowsBundle
    BuildScript -->|"packages"| LinuxTarball

    %% Click Events
    click EasyrsaScript "https://github.com/openvpn/easy-rsa/tree/master/easyrsa3/easyrsa"
    click OpenSslCnf "https://github.com/openvpn/easy-rsa/blob/master/easyrsa3/openssl-easyrsa.cnf"
    click VarsExample "https://github.com/openvpn/easy-rsa/blob/master/easyrsa3/vars.example"
    click X509Types "https://github.com/openvpn/easy-rsa/tree/master/easyrsa3/x509-types/"
    click WindowsBundle "https://github.com/openvpn/easy-rsa/tree/master/distro/windows/"
    click BuildScript "https://github.com/openvpn/easy-rsa/blob/master/build/build-dist.sh"
    click GitHubCI "https://github.com/openvpn/easy-rsa/blob/master/.github/workflows/action.yml"
    click doc "https://github.com/openvpn/easy-rsa/tree/master/doc/"

    %% Styles
    classDef runtime fill:#blue,stroke:#333,color:#fff
    classDef config fill:#0f0,stroke:#333,color:#000
    classDef build fill:#f90,stroke:#333,color:#000
    classDef data fill:#ccc,stroke:#333,color:#000
```
