mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-08 19:18:55 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb72292b83 | |||
| 3a11e447cf | |||
| bad02e6f23 | |||
| 4c3b7cbb16 | |||
| e8c64b47dd |
@@ -84,8 +84,9 @@ For the full capability breakdown — revocation infrastructure (CRL + OCSP), po
|
|||||||
| OpenSSL / Custom CA | Implemented | `OpenSSL` |
|
| OpenSSL / Custom CA | Implemented | `OpenSSL` |
|
||||||
| Vault PKI | Beta | `VaultPKI` |
|
| Vault PKI | Beta | `VaultPKI` |
|
||||||
| DigiCert CertCentral | Beta | `DigiCert` |
|
| DigiCert CertCentral | Beta | `DigiCert` |
|
||||||
|
| Sectigo SCM | Beta | `Sectigo` |
|
||||||
|
|
||||||
**Vault PKI and DigiCert connectors are in beta.** If you hit any bugs or unexpected behavior, please [open a GitHub issue](https://github.com/shankar0123/certctl/issues) -- we're actively testing these and want to hear from real users.
|
**Vault PKI, DigiCert, and Sectigo connectors are in beta.** If you hit any bugs or unexpected behavior, please [open a GitHub issue](https://github.com/shankar0123/certctl/issues) -- we're actively testing these and want to hear from real users.
|
||||||
|
|
||||||
**Note:** ADCS integration is handled via the Local CA's sub-CA mode — certctl operates as a subordinate CA with its signing certificate issued by ADCS. Any CA with a shell-accessible signing interface can be integrated today via the OpenSSL/Custom CA connector.
|
**Note:** ADCS integration is handled via the Local CA's sub-CA mode — certctl operates as a subordinate CA with its signing certificate issued by ADCS. Any CA with a shell-accessible signing interface can be integrated today via the OpenSSL/Custom CA connector.
|
||||||
|
|
||||||
@@ -211,18 +212,15 @@ Each directory contains a `docker-compose.yml` and a `README.md` explaining the
|
|||||||
|
|
||||||
| Guide | Description |
|
| Guide | Description |
|
||||||
|-------|-------------|
|
|-------|-------------|
|
||||||
| [Why certctl?](docs/why-certctl.md) | How certctl compares to open-source and enterprise certificate management platforms |
|
| [Why certctl?](docs/why-certctl.md) | How certctl compares to ACME clients, agent-based SaaS, and enterprise platforms |
|
||||||
| [Concepts](docs/concepts.md) | TLS certificates explained from scratch — for beginners who know nothing about certs |
|
| [Concepts](docs/concepts.md) | TLS certificates explained from scratch — for beginners who know nothing about certs |
|
||||||
| [Quick Start](docs/quickstart.md) | Extended quickstart — dashboard, API, CLI, discovery, stakeholder demo flow |
|
| [Quick Start](docs/quickstart.md) | 5-minute setup — dashboard, API, CLI, discovery, stakeholder demo flow |
|
||||||
|
| [Deployment Examples](docs/examples.md) | 5 turnkey scenarios (ACME+NGINX, wildcard DNS-01, private CA, step-ca, multi-issuer) with migration guides |
|
||||||
| [Advanced Demo](docs/demo-advanced.md) | Issue a certificate end-to-end with technical deep-dives |
|
| [Advanced Demo](docs/demo-advanced.md) | Issue a certificate end-to-end with technical deep-dives |
|
||||||
| [Architecture](docs/architecture.md) | System design, data flow diagrams, security model |
|
| [Architecture](docs/architecture.md) | System design, data flow diagrams, security model |
|
||||||
| [Feature Inventory](docs/features.md) | Complete reference of all V2 capabilities, API endpoints, and configuration |
|
| [Feature Inventory](docs/features.md) | Complete reference of all V2 capabilities, API endpoints, and configuration |
|
||||||
| [Configuration Reference](docs/features.md) | All 39 environment variables across server, agent, and connector config |
|
| [Connector Reference](docs/connectors.md) | Configuration for all 7 issuers, 10 targets, and 5 notifier connectors |
|
||||||
| [Connectors](docs/connectors.md) | Build custom issuer, target, and notifier connectors |
|
|
||||||
| [Compliance Mapping](docs/compliance.md) | SOC 2 Type II, PCI-DSS 4.0, NIST SP 800-57 alignment guides |
|
| [Compliance Mapping](docs/compliance.md) | SOC 2 Type II, PCI-DSS 4.0, NIST SP 800-57 alignment guides |
|
||||||
| [Migrate from Certbot](docs/migrate-from-certbot.md) | Step-by-step migration from Certbot/Let's Encrypt cron jobs |
|
|
||||||
| [Migrate from acme.sh](docs/migrate-from-acmesh.md) | Migration guide for acme.sh users with DNS-01 scripts |
|
|
||||||
| [certctl for cert-manager Users](docs/certctl-for-cert-manager-users.md) | Using certctl alongside cert-manager for non-Kubernetes infrastructure |
|
|
||||||
| [OpenAPI 3.1 Spec](api/openapi.yaml) | 97 operations, full request/response schemas |
|
| [OpenAPI 3.1 Spec](api/openapi.yaml) | 97 operations, full request/response schemas |
|
||||||
|
|
||||||
## CLI
|
## CLI
|
||||||
|
|||||||
+1
-1
@@ -2643,7 +2643,7 @@ components:
|
|||||||
# ─── Issuers ─────────────────────────────────────────────────────
|
# ─── Issuers ─────────────────────────────────────────────────────
|
||||||
IssuerType:
|
IssuerType:
|
||||||
type: string
|
type: string
|
||||||
enum: [ACME, GenericCA, StepCA, VaultPKI, DigiCert]
|
enum: [ACME, GenericCA, StepCA, VaultPKI, DigiCert, Sectigo]
|
||||||
|
|
||||||
Issuer:
|
Issuer:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
digicertissuer "github.com/shankar0123/certctl/internal/connector/issuer/digicert"
|
digicertissuer "github.com/shankar0123/certctl/internal/connector/issuer/digicert"
|
||||||
opensslissuer "github.com/shankar0123/certctl/internal/connector/issuer/openssl"
|
opensslissuer "github.com/shankar0123/certctl/internal/connector/issuer/openssl"
|
||||||
stepcaissuer "github.com/shankar0123/certctl/internal/connector/issuer/stepca"
|
stepcaissuer "github.com/shankar0123/certctl/internal/connector/issuer/stepca"
|
||||||
|
sectigoissuer "github.com/shankar0123/certctl/internal/connector/issuer/sectigo"
|
||||||
vaultissuer "github.com/shankar0123/certctl/internal/connector/issuer/vault"
|
vaultissuer "github.com/shankar0123/certctl/internal/connector/issuer/vault"
|
||||||
notifyemail "github.com/shankar0123/certctl/internal/connector/notifier/email"
|
notifyemail "github.com/shankar0123/certctl/internal/connector/notifier/email"
|
||||||
notifyopsgenie "github.com/shankar0123/certctl/internal/connector/notifier/opsgenie"
|
notifyopsgenie "github.com/shankar0123/certctl/internal/connector/notifier/opsgenie"
|
||||||
@@ -158,6 +159,19 @@ func main() {
|
|||||||
}, logger)
|
}, logger)
|
||||||
logger.Info("initialized DigiCert CertCentral issuer connector")
|
logger.Info("initialized DigiCert CertCentral issuer connector")
|
||||||
|
|
||||||
|
// Initialize Sectigo SCM issuer connector (for enterprise public CA).
|
||||||
|
// Uses the Sectigo SCM REST API with async order model.
|
||||||
|
sectigoConnector := sectigoissuer.New(§igoissuer.Config{
|
||||||
|
CustomerURI: cfg.Sectigo.CustomerURI,
|
||||||
|
Login: cfg.Sectigo.Login,
|
||||||
|
Password: cfg.Sectigo.Password,
|
||||||
|
OrgID: cfg.Sectigo.OrgID,
|
||||||
|
CertType: cfg.Sectigo.CertType,
|
||||||
|
Term: cfg.Sectigo.Term,
|
||||||
|
BaseURL: cfg.Sectigo.BaseURL,
|
||||||
|
}, logger)
|
||||||
|
logger.Info("initialized Sectigo SCM issuer connector")
|
||||||
|
|
||||||
// Build issuer registry: maps issuer IDs (from database) to connector implementations.
|
// Build issuer registry: maps issuer IDs (from database) to connector implementations.
|
||||||
// "iss-local" matches the seed data issuer ID for the Local CA.
|
// "iss-local" matches the seed data issuer ID for the Local CA.
|
||||||
// "iss-acme-staging" and "iss-acme-prod" are conventional IDs for ACME issuers.
|
// "iss-acme-staging" and "iss-acme-prod" are conventional IDs for ACME issuers.
|
||||||
@@ -183,6 +197,12 @@ func main() {
|
|||||||
logger.Info("DigiCert CertCentral issuer registered", "id", "iss-digicert")
|
logger.Info("DigiCert CertCentral issuer registered", "id", "iss-digicert")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Conditionally register Sectigo SCM (only if all 3 auth credentials are set)
|
||||||
|
if cfg.Sectigo.CustomerURI != "" && cfg.Sectigo.Login != "" && cfg.Sectigo.Password != "" {
|
||||||
|
issuerRegistry["iss-sectigo"] = service.NewIssuerConnectorAdapter(sectigoConnector)
|
||||||
|
logger.Info("Sectigo SCM issuer registered", "id", "iss-sectigo")
|
||||||
|
}
|
||||||
|
|
||||||
logger.Info("issuer registry configured", "issuers", len(issuerRegistry))
|
logger.Info("issuer registry configured", "issuers", len(issuerRegistry))
|
||||||
|
|
||||||
// Initialize revocation repository
|
// Initialize revocation repository
|
||||||
|
|||||||
@@ -90,8 +90,10 @@ flowchart TB
|
|||||||
T5["HAProxy\n(combined PEM + reload)"]
|
T5["HAProxy\n(combined PEM + reload)"]
|
||||||
T6["Traefik\n(file provider)"]
|
T6["Traefik\n(file provider)"]
|
||||||
T7["Caddy\n(admin API / file)"]
|
T7["Caddy\n(admin API / file)"]
|
||||||
|
T8["Envoy\n(file-based SDS)"]
|
||||||
|
T9["Postfix/Dovecot\n(file + service reload)"]
|
||||||
T2["F5 BIG-IP\n(proxy agent + iControl REST, planned)"]
|
T2["F5 BIG-IP\n(proxy agent + iControl REST, planned)"]
|
||||||
T3["IIS\n(agent-local PowerShell, planned)"]
|
T3["IIS\n(WinRM + local)"]
|
||||||
end
|
end
|
||||||
|
|
||||||
DASH --> API
|
DASH --> API
|
||||||
@@ -119,7 +121,7 @@ The server exposes a REST API under `/api/v1/` and optionally serves the web das
|
|||||||
|
|
||||||
### Agents
|
### Agents
|
||||||
|
|
||||||
Lightweight Go processes that run on or near your infrastructure. Agents generate ECDSA P-256 private keys locally, create CSRs, and submit them to the control plane for signing — private keys never leave agent infrastructure. Agents also handle certificate deployment to target systems (NGINX, Apache httpd, HAProxy fully implemented; F5 BIG-IP, IIS interface only with V2 implementations planned) and report job status. They communicate with the control plane via HTTP and authenticate with API keys.
|
Lightweight Go processes that run on or near your infrastructure. Agents generate ECDSA P-256 private keys locally, create CSRs, and submit them to the control plane for signing — private keys never leave agent infrastructure. Agents also handle certificate deployment to target systems (NGINX, Apache httpd, HAProxy, Traefik, Caddy, Envoy, Postfix, Dovecot, IIS fully implemented; F5 BIG-IP interface stub only) and report job status. They communicate with the control plane via HTTP and authenticate with API keys.
|
||||||
|
|
||||||
The agent runs two background loops: a heartbeat (every 60 seconds) to signal it's alive, and a work poll (every 30 seconds) to check for actionable jobs via `GET /api/v1/agents/{id}/work`. Jobs may be `AwaitingCSR` (agent needs to generate key + submit CSR) or `Deployment` (agent needs to deploy a certificate). Private keys are stored in `CERTCTL_KEY_DIR` (default `/var/lib/certctl/keys`) with 0600 permissions.
|
The agent runs two background loops: a heartbeat (every 60 seconds) to signal it's alive, and a work poll (every 30 seconds) to check for actionable jobs via `GET /api/v1/agents/{id}/work`. Jobs may be `AwaitingCSR` (agent needs to generate key + submit CSR) or `Deployment` (agent needs to deploy a certificate). Private keys are stored in `CERTCTL_KEY_DIR` (default `/var/lib/certctl/keys`) with 0600 permissions.
|
||||||
|
|
||||||
@@ -511,6 +513,7 @@ flowchart TB
|
|||||||
II --> OC["OpenSSL / Custom CA"]
|
II --> OC["OpenSSL / Custom CA"]
|
||||||
II --> VP["Vault PKI"]
|
II --> VP["Vault PKI"]
|
||||||
II --> DC["DigiCert CertCentral"]
|
II --> DC["DigiCert CertCentral"]
|
||||||
|
II --> SG["Sectigo SCM"]
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph "Target Connectors"
|
subgraph "Target Connectors"
|
||||||
@@ -521,8 +524,10 @@ flowchart TB
|
|||||||
TI --> HP["HAProxy"]
|
TI --> HP["HAProxy"]
|
||||||
TI --> TF["Traefik"]
|
TI --> TF["Traefik"]
|
||||||
TI --> CD["Caddy"]
|
TI --> CD["Caddy"]
|
||||||
|
TI --> EV["Envoy"]
|
||||||
|
TI --> PO["Postfix/Dovecot"]
|
||||||
|
TI --> IIS["IIS"]
|
||||||
TI --> F5["F5 BIG-IP (interface only)"]
|
TI --> F5["F5 BIG-IP (interface only)"]
|
||||||
TI --> IIS["IIS (interface only)"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph "Notifier Connectors"
|
subgraph "Notifier Connectors"
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Agents scan configured directories and report back all existing certs. In the da
|
|||||||
Set up the same issuer certctl uses for non-Kubernetes certs:
|
Set up the same issuer certctl uses for non-Kubernetes certs:
|
||||||
- **ACME** (Let's Encrypt, for public certs)
|
- **ACME** (Let's Encrypt, for public certs)
|
||||||
- **step-ca** (Smallstep, for internal certs)
|
- **step-ca** (Smallstep, for internal certs)
|
||||||
- **Vault PKI** (planned) (HashiCorp Vault, for enterprise PKI)
|
- **Vault PKI** (HashiCorp Vault, for enterprise PKI)
|
||||||
- **Private CA** (your own internal root CA)
|
- **Private CA** (your own internal root CA)
|
||||||
|
|
||||||
No new CA infrastructure needed. If cert-manager already uses your CA, certctl points to the same one.
|
No new CA infrastructure needed. If cert-manager already uses your CA, certctl points to the same one.
|
||||||
@@ -115,7 +115,7 @@ Certificates are linked to issuers and profiles when created or claimed from dis
|
|||||||
If cert-manager and certctl both use the same CA:
|
If cert-manager and certctl both use the same CA:
|
||||||
- **ACME**: cert-manager uses ClusterIssuer + certctl uses ACME connector → same Let's Encrypt account, transparent coexistence
|
- **ACME**: cert-manager uses ClusterIssuer + certctl uses ACME connector → same Let's Encrypt account, transparent coexistence
|
||||||
- **step-ca**: cert-manager uses external issuer CRD + certctl uses step-ca connector → same provisioner, shared certificate inventory
|
- **step-ca**: cert-manager uses external issuer CRD + certctl uses step-ca connector → same provisioner, shared certificate inventory
|
||||||
- **Vault PKI** (planned): cert-manager uses external issuer CRD + certctl uses Vault connector → same mount, same audit trail
|
- **Vault PKI**: cert-manager uses external issuer CRD + certctl uses Vault connector → same mount, same audit trail
|
||||||
|
|
||||||
No conflict. They just issue certs through the same CA. certctl's discovery scanning finds cert-manager-issued certs and shows them alongside certctl-managed ones.
|
No conflict. They just issue certs through the same CA. certctl's discovery scanning finds cert-manager-issued certs and shows them alongside certctl-managed ones.
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ For now: cert-manager handles Kubernetes, certctl handles everything else. They
|
|||||||
|
|
||||||
## Next Steps
|
## Next Steps
|
||||||
|
|
||||||
1. Review [Quick Start](./quickstart.md) for a 5-minute demo
|
1. Run through the [Quick Start](./quickstart.md) for a 5-minute demo
|
||||||
2. Explore [Architecture](./architecture.md#agents) for deployment architecture
|
2. Try the [Multi-Issuer example](../examples/multi-issuer/multi-issuer.md) — manages public and internal certs from one dashboard
|
||||||
3. Read about [Discovery Scanning](./quickstart.md#certificate-discovery) to auto-find certs
|
3. Explore [Architecture](./architecture.md#agents) for deployment patterns
|
||||||
4. Check [Helm Chart](../deploy/helm/certctl/) for production Kubernetes deployment
|
4. Check the [Helm Chart](../deploy/helm/certctl/) for production Kubernetes deployment
|
||||||
|
|||||||
+2
-2
@@ -125,9 +125,9 @@ Agents also report **metadata** about themselves — their operating system, CPU
|
|||||||
|
|
||||||
### Deployment Targets
|
### Deployment Targets
|
||||||
|
|
||||||
Targets are the systems where certificates actually get installed — NGINX web servers, Apache httpd servers, HAProxy load balancers, F5 BIG-IP appliances, Microsoft IIS servers. Each target type has a **connector** that knows how to deploy certificates to that specific system (e.g., writing files and reloading NGINX or Apache config, building a combined PEM for HAProxy).
|
Targets are the systems where certificates actually get installed — NGINX web servers, Apache httpd servers, HAProxy load balancers, Traefik reverse proxies, Caddy servers, Envoy gateways, Postfix/Dovecot mail servers, Microsoft IIS servers, and network appliances. Each target type has a **connector** that knows how to deploy certificates to that specific system (e.g., writing files and reloading NGINX or Apache config, building a combined PEM for HAProxy).
|
||||||
|
|
||||||
For targets where an agent runs directly on the machine (NGINX, Apache, HAProxy, IIS), the agent deploys certificates locally — no remote access needed. For network appliances where you can't install an agent (F5 BIG-IP, Palo Alto, etc.), a **proxy agent** in the same network zone picks up the deployment job and calls the appliance's API. The server never initiates outbound connections to any target.
|
For targets where an agent runs directly on the machine (NGINX, Apache, HAProxy, Traefik, Caddy, Envoy, Postfix, Dovecot, IIS), the agent deploys certificates locally — no remote access needed. For network appliances where you can't install an agent (F5 BIG-IP, Palo Alto, etc.), a **proxy agent** in the same network zone picks up the deployment job and calls the appliance's API. The server never initiates outbound connections to any target.
|
||||||
|
|
||||||
## The Certificate Lifecycle
|
## The Certificate Lifecycle
|
||||||
|
|
||||||
|
|||||||
+26
-3
@@ -53,8 +53,8 @@ Connectors extend certctl to integrate with external systems for certificate iss
|
|||||||
|
|
||||||
Three types of connectors:
|
Three types of connectors:
|
||||||
|
|
||||||
1. **Issuer Connector** — Obtains certificates from CAs (Local CA with sub-CA support, ACME with HTTP-01 + DNS-01 + DNS-PERSIST-01, step-ca, OpenSSL/Custom CA implemented; additional CA integrations planned)
|
1. **Issuer Connector** — Obtains certificates from CAs (Local CA with sub-CA support, ACME with HTTP-01 + DNS-01 + DNS-PERSIST-01, step-ca, OpenSSL/Custom CA, Vault PKI, DigiCert implemented; additional CA integrations planned)
|
||||||
2. **Target Connector** — Deploys certificates to infrastructure (NGINX, Apache httpd, HAProxy, Traefik, Caddy, Envoy, IIS implemented; F5 via proxy agent planned; additional cloud and network targets planned)
|
2. **Target Connector** — Deploys certificates to infrastructure (NGINX, Apache httpd, HAProxy, Traefik, Caddy, Envoy, Postfix, Dovecot, IIS implemented; F5 via proxy agent planned; additional cloud and network targets planned)
|
||||||
3. **Notifier Connector** — Sends alerts about certificate events (Email, Webhooks, Slack, Microsoft Teams, PagerDuty, OpsGenie implemented)
|
3. **Notifier Connector** — Sends alerts about certificate events (Email, Webhooks, Slack, Microsoft Teams, PagerDuty, OpsGenie implemented)
|
||||||
|
|
||||||
All connectors accept JSON configuration at initialization, support config validation, and are registered in the service layer. Issuer connectors run on the control plane; target connectors run on agents. For network appliances where agents can't be installed, a **proxy agent** in the same network zone handles deployment — the server never initiates outbound connections.
|
All connectors accept JSON configuration at initialization, support config validation, and are registered in the service layer. Issuer connectors run on the control plane; target connectors run on agents. For network appliances where agents can't be installed, a **proxy agent** in the same network zone handles deployment — the server never initiates outbound connections.
|
||||||
@@ -355,12 +355,35 @@ The connector submits certificate orders to DigiCert's `/order/certificate/creat
|
|||||||
|
|
||||||
Location: `internal/connector/issuer/digicert/digicert.go`
|
Location: `internal/connector/issuer/digicert/digicert.go`
|
||||||
|
|
||||||
|
### Built-in: Sectigo SCM
|
||||||
|
|
||||||
|
The Sectigo connector integrates with Sectigo Certificate Manager's REST API for ordering and managing DV, OV, and EV certificates. Like DigiCert, it uses an async order model: submit an enrollment, receive an sslId, then poll for completion.
|
||||||
|
|
||||||
|
**Configuration:**
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `CERTCTL_SECTIGO_CUSTOMER_URI` | — | Sectigo customer URI (organization identifier) |
|
||||||
|
| `CERTCTL_SECTIGO_LOGIN` | — | API account login |
|
||||||
|
| `CERTCTL_SECTIGO_PASSWORD` | — | API account password |
|
||||||
|
| `CERTCTL_SECTIGO_ORG_ID` | — | Organization ID (integer) |
|
||||||
|
| `CERTCTL_SECTIGO_CERT_TYPE` | — | Certificate type ID (integer, from `/ssl/v1/types`) |
|
||||||
|
| `CERTCTL_SECTIGO_TERM` | `365` | Certificate validity in days |
|
||||||
|
| `CERTCTL_SECTIGO_BASE_URL` | `https://cert-manager.com/api` | Sectigo API base URL |
|
||||||
|
|
||||||
|
The connector submits certificate enrollments to Sectigo's `/ssl/v1/enroll` API. DV certificates may issue immediately; OV/EV certificates require validation (handled by Sectigo) and poll-based completion. The connector periodically checks enrollment status via `/ssl/v1/{sslId}` and downloads the PEM bundle via `/ssl/v1/collect/{sslId}/pem` when issued.
|
||||||
|
|
||||||
|
**Authentication:** Three custom headers on every request — `customerUri`, `login`, and `password`.
|
||||||
|
|
||||||
|
**Note:** CRL and OCSP are managed by Sectigo. certctl records revocations locally and notifies Sectigo via `/ssl/v1/revoke/{sslId}`.
|
||||||
|
|
||||||
|
Location: `internal/connector/issuer/sectigo/sectigo.go`
|
||||||
|
|
||||||
### Coming in V2.2+
|
### Coming in V2.2+
|
||||||
|
|
||||||
The following issuer connectors are planned for future releases:
|
The following issuer connectors are planned for future releases:
|
||||||
|
|
||||||
- **Entrust** — Enterprise CA via Entrust API
|
- **Entrust** — Enterprise CA via Entrust API
|
||||||
- **Sectigo** — Commercial CA integration via Sectigo REST API
|
|
||||||
- **Google CAS** — Google Cloud Certificate Authority Service
|
- **Google CAS** — Google Cloud Certificate Authority Service
|
||||||
- **AWS ACM Private CA** — AWS-managed private CA
|
- **AWS ACM Private CA** — AWS-managed private CA
|
||||||
|
|
||||||
|
|||||||
@@ -307,8 +307,8 @@ flowchart TD
|
|||||||
A --> F["ACME\n(Let's Encrypt)"]
|
A --> F["ACME\n(Let's Encrypt)"]
|
||||||
A --> G["step-ca\n(implemented)"]
|
A --> G["step-ca\n(implemented)"]
|
||||||
A --> H["OpenSSL / Custom CA\n(script-based)"]
|
A --> H["OpenSSL / Custom CA\n(script-based)"]
|
||||||
A --> J["DigiCert API\n(planned)"]
|
A --> J["DigiCert API\n(implemented)"]
|
||||||
A --> K["Vault PKI\n(planned)"]
|
A --> K["Vault PKI\n(implemented)"]
|
||||||
A --> L["Entrust / GlobalSign\n(planned)"]
|
A --> L["Entrust / GlobalSign\n(planned)"]
|
||||||
A --> M["Google CAS / EJBCA\n(planned)"]
|
A --> M["Google CAS / EJBCA\n(planned)"]
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
# Deployment Examples
|
||||||
|
|
||||||
|
Five turnkey docker-compose scenarios, each runnable in under 5 minutes. Pick the one closest to your setup.
|
||||||
|
|
||||||
|
## Which Example Should I Use?
|
||||||
|
|
||||||
|
| I need to... | Example | Issuer | Target |
|
||||||
|
|--------------|---------|--------|--------|
|
||||||
|
| Get Let's Encrypt certs for NGINX on a public server | [ACME + NGINX](#acme--nginx) | ACME (HTTP-01) | NGINX |
|
||||||
|
| Issue wildcard certs without opening port 80 | [Wildcard DNS-01](#wildcard-dns-01) | ACME (DNS-01) | Any |
|
||||||
|
| Run an internal CA for services behind a firewall | [Private CA + Traefik](#private-ca--traefik) | Local CA | Traefik |
|
||||||
|
| Use Smallstep step-ca as my PKI backend | [step-ca + HAProxy](#step-ca--haproxy) | step-ca | HAProxy |
|
||||||
|
| Manage both public and internal certs from one dashboard | [Multi-Issuer](#multi-issuer) | ACME + Local CA | Mixed |
|
||||||
|
|
||||||
|
**Already using another tool?** See the migration sections below each example for Certbot, acme.sh, and cert-manager users.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ACME + NGINX
|
||||||
|
|
||||||
|
**Scenario:** You have one or more public-facing domains, NGINX as the reverse proxy, and want automated Let's Encrypt certificates with HTTP-01 challenges.
|
||||||
|
|
||||||
|
**What it deploys:** certctl server + PostgreSQL + certctl agent + NGINX, all on one Docker network. The agent generates keys locally (ECDSA P-256), submits CSRs to the server, receives signed certs from Let's Encrypt, and deploys them to NGINX with automatic reload.
|
||||||
|
|
||||||
|
**Prerequisites:** A domain pointing to your server, ports 80 and 443 open, Docker Compose v20.10+.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd examples/acme-nginx
|
||||||
|
cp .env.example .env # Edit with your domain and email
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
The full walkthrough — including how HTTP-01 challenges work, adding multiple domains, switching to staging for testing, and a production checklist — is in the [example README](../examples/acme-nginx/acme-nginx.md).
|
||||||
|
|
||||||
|
**Migrating from Certbot?** certctl discovers your existing `/etc/letsencrypt/live/` certificates automatically. You keep your ACME account, disable the Certbot cron, and certctl takes over renewal with centralized visibility and deployment verification. The step-by-step process is in [Migrating from Certbot](migrate-from-certbot.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Wildcard DNS-01
|
||||||
|
|
||||||
|
**Scenario:** You need wildcard certificates (`*.example.com`) or your servers aren't reachable from the internet (no port 80). DNS-01 validates ownership by creating a TXT record at your DNS provider.
|
||||||
|
|
||||||
|
**What it deploys:** certctl server + PostgreSQL + certctl agent. Includes a Cloudflare DNS hook script as a working reference — swap in your own DNS provider (Route53, Azure DNS, Google Cloud DNS, or any provider with an API).
|
||||||
|
|
||||||
|
**Prerequisites:** A domain, API credentials for your DNS provider, Docker Compose.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd examples/acme-wildcard-dns01
|
||||||
|
cp .env.example .env # Edit with domain, email, DNS provider credentials
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
The full walkthrough — including DNS-PERSIST-01 (set a TXT record once, never touch DNS again on renewals), adapting scripts for other providers, and propagation troubleshooting — is in the [example README](../examples/acme-wildcard-dns01/acme-wildcard-dns01.md).
|
||||||
|
|
||||||
|
**Migrating from acme.sh?** Your existing `dns_*` hook scripts are compatible with certctl's DNS-01 — they use the same pattern (shell scripts creating TXT records). The migration guide covers script adaptation, discovery of existing acme.sh certificates, and phasing out the acme.sh cron. See [Migrating from acme.sh](migrate-from-acmesh.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Private CA + Traefik
|
||||||
|
|
||||||
|
**Scenario:** Internal services that don't need public CA validation. You run your own certificate authority — either a self-signed root for development, or a subordinate CA chained to your enterprise root (e.g., Active Directory Certificate Services).
|
||||||
|
|
||||||
|
**What it deploys:** certctl server + PostgreSQL + certctl agent + Traefik. The Local CA issuer signs certificates directly. Traefik watches a cert directory and auto-reloads when new files appear.
|
||||||
|
|
||||||
|
**Prerequisites:** Docker Compose. For sub-CA mode, you'll need a CA certificate and key signed by your enterprise root.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd examples/private-ca-traefik
|
||||||
|
docker compose up -d # Self-signed mode (no .env needed for demo)
|
||||||
|
```
|
||||||
|
|
||||||
|
The full walkthrough — including sub-CA setup with `CERTCTL_CA_CERT_PATH` and `CERTCTL_CA_KEY_PATH`, creating certificates via the API, monitoring deployments, and production hardening — is in the [example README](../examples/private-ca-traefik/private-ca-traefik.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## step-ca + HAProxy
|
||||||
|
|
||||||
|
**Scenario:** You use Smallstep's step-ca as your private PKI and want automated lifecycle management for certificates deployed to HAProxy load balancers.
|
||||||
|
|
||||||
|
**What it deploys:** certctl server + PostgreSQL + certctl agent + step-ca (with JWK provisioner) + HAProxy. certctl issues certs via step-ca's native `/sign` API, combines them into HAProxy's expected PEM format (cert + chain + key in one file), and reloads HAProxy.
|
||||||
|
|
||||||
|
**Prerequisites:** Docker Compose.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd examples/step-ca-haproxy
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
The full walkthrough — including step-ca provisioner configuration, integrating with an existing step-ca instance, HAProxy PEM format details, and advanced features (approval workflows, policy-based renewal, multi-instance HAProxy) — is in the [example README](../examples/step-ca-haproxy/step-ca-haproxy.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Multi-Issuer
|
||||||
|
|
||||||
|
**Scenario:** You manage both public-facing services (needing Let's Encrypt or another public CA) and internal services (using a private CA) and want a single dashboard for everything.
|
||||||
|
|
||||||
|
**What it deploys:** certctl server + PostgreSQL + certctl agent configured with both an ACME issuer and a Local CA issuer. Demonstrates issuer assignment via profiles — public services get ACME certs, internal services get Local CA certs, all visible in one inventory.
|
||||||
|
|
||||||
|
**Prerequisites:** Docker Compose. For real ACME certs, a public domain and port 80 access.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd examples/multi-issuer
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
The full walkthrough — including profile-based issuer assignment, testing with ACME staging, Local CA enterprise sub-CA mode, and scaling beyond Docker Compose — is in the [example README](../examples/multi-issuer/multi-issuer.md).
|
||||||
|
|
||||||
|
**Using cert-manager for Kubernetes?** certctl complements cert-manager — cert-manager handles in-cluster certs, certctl handles everything outside: VMs, bare metal, network appliances, Windows servers. They can share the same CA (ACME, step-ca, Vault PKI). See [certctl for cert-manager Users](certctl-for-cert-manager-users.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Beyond These Examples
|
||||||
|
|
||||||
|
These 5 scenarios cover the most common deployment patterns, but certctl supports 7 issuer backends and 10 target connectors. Once you have the basics running, you can mix and match:
|
||||||
|
|
||||||
|
**Issuers:** ACME (Let's Encrypt, ZeroSSL, Buypass, Google Trust Services), Local CA (self-signed or sub-CA), step-ca, Vault PKI, DigiCert CertCentral, OpenSSL/Custom CA script, Sectigo (coming soon).
|
||||||
|
|
||||||
|
**Targets:** NGINX, Apache, HAProxy, Traefik, Caddy, Envoy, IIS (local PowerShell or WinRM proxy), Postfix, Dovecot, F5 BIG-IP (coming soon).
|
||||||
|
|
||||||
|
See [Connector Reference](connectors.md) for configuration details on every issuer and target.
|
||||||
+7
-7
@@ -1286,11 +1286,11 @@ The web dashboard is the primary operational interface for certctl. Built with *
|
|||||||
- **Docker Tags** — `:latest`, `:v{version}` (`shankar0123.docker.scarf.sh/certctl-server`, `shankar0123.docker.scarf.sh/certctl-agent`)
|
- **Docker Tags** — `:latest`, `:v{version}` (`shankar0123.docker.scarf.sh/certctl-server`, `shankar0123.docker.scarf.sh/certctl-agent`)
|
||||||
|
|
||||||
### Test Suite
|
### Test Suite
|
||||||
- **Unit Tests** — 625+ test functions across service, handler, middleware, domain layers
|
- **Unit Tests** — 1,088+ test functions across service, handler, middleware, domain layers
|
||||||
- **Integration Tests** — End-to-end workflows (issuance→renewal→deployment)
|
- **Integration Tests** — End-to-end workflows (issuance→renewal→deployment)
|
||||||
- **Negative Tests** — Malformed input, nonexistent resources, error conditions
|
- **Negative Tests** — Malformed input, nonexistent resources, error conditions
|
||||||
- **Frontend Tests** — 86 Vitest tests (API client, utilities, stats/metrics, full endpoint coverage)
|
- **Frontend Tests** — 211 Vitest tests (API client, utilities, stats/metrics, full endpoint coverage)
|
||||||
- **Total Coverage** — 900+ tests (Go + frontend combined)
|
- **Total Coverage** — 1,554+ tests (Go + frontend combined)
|
||||||
|
|
||||||
### Licensing
|
### Licensing
|
||||||
- **License** — Business Source License 1.1 (BSL 1.1)
|
- **License** — Business Source License 1.1 (BSL 1.1)
|
||||||
@@ -1478,10 +1478,10 @@ Each guide includes an evidence summary table mapping specific criteria to certc
|
|||||||
|
|
||||||
| Category | Count |
|
| Category | Count |
|
||||||
|----------|-------|
|
|----------|-------|
|
||||||
| **API Endpoints** | 95 (under /api/v1/ + /.well-known/est/) |
|
| **API Endpoints** | 97 (under /api/v1/ + /.well-known/est/) |
|
||||||
| **Dashboard** | Full web GUI |
|
| **Dashboard** | Full web GUI |
|
||||||
| **Issuer Connectors** | 4 (Local CA, ACME, step-ca, OpenSSL) |
|
| **Issuer Connectors** | 6 (Local CA, ACME, step-ca, OpenSSL, Vault PKI, DigiCert) |
|
||||||
| **Target Connectors** | 5 (3 impl: NGINX, Apache, HAProxy; 2 stubs: F5, IIS) |
|
| **Target Connectors** | 10 (9 impl: NGINX, Apache, HAProxy, Traefik, Caddy, Envoy, IIS, Postfix, Dovecot; 1 stub: F5) |
|
||||||
| **Notifier Channels** | 6 (Email, Webhook, Slack, Teams, PagerDuty, OpsGenie) |
|
| **Notifier Channels** | 6 (Email, Webhook, Slack, Teams, PagerDuty, OpsGenie) |
|
||||||
| **Job Types** | 4 (Issuance, Renewal, Deployment, Validation) |
|
| **Job Types** | 4 (Issuance, Renewal, Deployment, Validation) |
|
||||||
| **Job States** | 7 (Pending, AwaitingCSR, AwaitingApproval, Running, Completed, Failed, Cancelled) |
|
| **Job States** | 7 (Pending, AwaitingCSR, AwaitingApproval, Running, Completed, Failed, Cancelled) |
|
||||||
@@ -1492,6 +1492,6 @@ Each guide includes an evidence summary table mapping specific criteria to certc
|
|||||||
| **MCP Tools** | 76 (16 resource domains) |
|
| **MCP Tools** | 76 (16 resource domains) |
|
||||||
| **CLI Subcommands** | 10 |
|
| **CLI Subcommands** | 10 |
|
||||||
| **Database Tables** | 19 |
|
| **Database Tables** | 19 |
|
||||||
| **Test Suite** | 900+ tests (Go backend + frontend) |
|
| **Test Suite** | 1,554+ tests (Go backend + frontend) |
|
||||||
| **Environment Variables** | 41+ configuration options |
|
| **Environment Variables** | 41+ configuration options |
|
||||||
|
|
||||||
|
|||||||
@@ -267,8 +267,9 @@ export CERTCTL_ACME_DNS_PRESENT_SCRIPT=/etc/certctl/dns/cloudflare-present.sh
|
|||||||
|
|
||||||
certctl automatically falls back to DNS-01 if the CA doesn't support dns-persist-01 yet.
|
certctl automatically falls back to DNS-01 if the CA doesn't support dns-persist-01 yet.
|
||||||
|
|
||||||
## Support
|
## Next Steps
|
||||||
|
|
||||||
See [Connector Configuration](connectors.md) for advanced ACME options (EAB, ARI, custom timeouts).
|
- Try the [Wildcard DNS-01 example](../examples/acme-wildcard-dns01/acme-wildcard-dns01.md) — a working docker-compose with Cloudflare hooks you can adapt for your DNS provider
|
||||||
|
- See [Connector Reference](connectors.md) for advanced ACME options (EAB, ARI, custom timeouts)
|
||||||
See [Discovery Guide](concepts.md#certificate-discovery) for managing discovered certificates at scale.
|
- See [Discovery Guide](concepts.md#certificate-discovery) for managing discovered certificates at scale
|
||||||
|
- See all [Deployment Examples](./examples.md) for other scenarios (ACME+NGINX, private CA, step-ca, multi-issuer)
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ certctl will stop renewing that cert when the policy is disabled. Certbot resume
|
|||||||
|
|
||||||
## Next Steps
|
## Next Steps
|
||||||
|
|
||||||
|
- Try the [ACME + NGINX example](../examples/acme-nginx/acme-nginx.md) — a working docker-compose you can run locally before deploying to production
|
||||||
- Review the [Concepts Guide](./concepts.md) for terminology (profiles, policies, agents, jobs)
|
- Review the [Concepts Guide](./concepts.md) for terminology (profiles, policies, agents, jobs)
|
||||||
- Explore [Network Discovery](./quickstart.md#network-discovery-agentless) to find certificates you didn't know about
|
- Explore [Network Discovery](./quickstart.md#network-discovery-agentless) to find certificates you didn't know about
|
||||||
- Set up [Kubernetes cert-manager integration](./certctl-for-cert-manager-users.md) if you manage in-cluster certs too
|
- See all [Deployment Examples](./examples.md) for other scenarios (wildcard DNS-01, private CA, step-ca, multi-issuer)
|
||||||
|
|||||||
+4
-1
@@ -461,7 +461,10 @@ The `-v` flag removes the PostgreSQL data volume for a clean slate.
|
|||||||
|
|
||||||
## What's Next
|
## What's Next
|
||||||
|
|
||||||
|
**Ready to deploy with your stack?** The [Deployment Examples](examples.md) page has 5 turnkey docker-compose scenarios — pick the one closest to your setup and have it running in minutes. It also covers migration paths from Certbot, acme.sh, and cert-manager.
|
||||||
|
|
||||||
|
- **[Deployment Examples](examples.md)** — ACME+NGINX, wildcard DNS-01, private CA+Traefik, step-ca+HAProxy, multi-issuer
|
||||||
- **[Advanced Demo](demo-advanced.md)** — Issue a real certificate via the Local CA end-to-end
|
- **[Advanced Demo](demo-advanced.md)** — Issue a real certificate via the Local CA end-to-end
|
||||||
- **[Architecture](architecture.md)** — How the control plane, agents, and connectors work together
|
- **[Architecture](architecture.md)** — How the control plane, agents, and connectors work together
|
||||||
- **[Connector Guide](connectors.md)** — Build custom connectors for your infrastructure
|
- **[Connector Reference](connectors.md)** — Configuration for all 7 issuers and 10 targets
|
||||||
- **[Concepts Guide](concepts.md)** — TLS certificates, CAs, and private keys explained from scratch
|
- **[Concepts Guide](concepts.md)** — TLS certificates, CAs, and private keys explained from scratch
|
||||||
|
|||||||
+76
-5
@@ -1600,7 +1600,7 @@ curl -s -w "\nHTTP %{http_code}\n" -X POST -H "$AUTH" -H "$CT" \
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Test 7.1.6 — Create IIS target (stub)**
|
**Test 7.1.6 — Create IIS target**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -s -w "\nHTTP %{http_code}\n" -X POST -H "$AUTH" -H "$CT" \
|
curl -s -w "\nHTTP %{http_code}\n" -X POST -H "$AUTH" -H "$CT" \
|
||||||
@@ -5833,7 +5833,7 @@ These must be green before starting manual QA:
|
|||||||
| 7.1.3 | Create Apache target | Manual | ☐ | | |
|
| 7.1.3 | Create Apache target | Manual | ☐ | | |
|
||||||
| 7.1.4 | Create HAProxy target | Manual | ☐ | | |
|
| 7.1.4 | Create HAProxy target | Manual | ☐ | | |
|
||||||
| 7.1.5 | Create F5 BIG-IP target (stub) | Auto | ☑ | 2026-03-30 | |
|
| 7.1.5 | Create F5 BIG-IP target (stub) | Auto | ☑ | 2026-03-30 | |
|
||||||
| 7.1.6 | Create IIS target (stub) | Auto | ☑ | 2026-03-30 | |
|
| 7.1.6 | Create IIS target | Auto | ☑ | 2026-03-30 | |
|
||||||
| 7.1.7 | Get target verifies type-specific config stored | Manual | ☐ | | |
|
| 7.1.7 | Get target verifies type-specific config stored | Manual | ☐ | | |
|
||||||
| 7.1.8 | Update target config | Manual | ☐ | | |
|
| 7.1.8 | Update target config | Manual | ☐ | | |
|
||||||
| 7.1.9 | Delete target returns 204 | Auto | ☑ | 2026-03-30 | |
|
| 7.1.9 | Delete target returns 204 | Auto | ☑ | 2026-03-30 | |
|
||||||
@@ -6314,15 +6314,86 @@ These must be green before starting manual QA:
|
|||||||
| 41.m8 | Discovery table — CA badge | Manual | ☐ | | |
|
| 41.m8 | Discovery table — CA badge | Manual | ☐ | | |
|
||||||
| 41.m9 | Fleet overview — macOS display | Manual | ☐ | | |
|
| 41.m9 | Fleet overview — macOS display | Manual | ☐ | | |
|
||||||
|
|
||||||
|
### Part 43: Sectigo SCM Connector (M43)
|
||||||
|
|
||||||
|
**Prerequisites:** Sectigo SCM account with API access, valid customerUri + login + password credentials, at least one cert type available in `/ssl/v1/types`.
|
||||||
|
|
||||||
|
#### Automated Tests
|
||||||
|
|
||||||
|
| Test | Description | Method | Pass? | Date | Notes |
|
||||||
|
|------|-------------|--------|-------|------|-------|
|
||||||
|
| 43.s1 | `IssuerTypeSectigo` constant exists in domain | Auto | ☐ | | `grep 'Sectigo' internal/domain/connector.go` |
|
||||||
|
| 43.s2 | `SectigoConfig` struct exists in config | Auto | ☐ | | `grep 'SectigoConfig' internal/config/config.go` |
|
||||||
|
| 43.s3 | `iss-sectigo` in seed_demo.sql | Auto | ☐ | | `grep 'iss-sectigo' migrations/seed_demo.sql` |
|
||||||
|
| 43.s4 | Sectigo in OpenAPI IssuerType enum | Auto | ☐ | | `grep 'Sectigo' api/openapi.yaml` |
|
||||||
|
| 43.s5 | Sectigo connector tests pass | Auto | ☐ | | `go test ./internal/connector/issuer/sectigo/... -v` |
|
||||||
|
| 43.s6 | Sectigo in issuerTypes.ts | Auto | ☐ | | `grep 'Sectigo' web/src/config/issuerTypes.ts` |
|
||||||
|
| 43.s7 | Frontend build succeeds | Auto | ☐ | | `cd web && npm run build` |
|
||||||
|
| 43.s8 | Full Go build succeeds | Auto | ☐ | | `go build ./cmd/server/... ./cmd/agent/... ./cmd/cli/... ./cmd/mcp-server/...` |
|
||||||
|
|
||||||
|
#### Manual Tests
|
||||||
|
|
||||||
|
**43.M1: Validate Sectigo Credentials**
|
||||||
|
|
||||||
|
1. Configure env vars: `CERTCTL_SECTIGO_CUSTOMER_URI`, `CERTCTL_SECTIGO_LOGIN`, `CERTCTL_SECTIGO_PASSWORD`, `CERTCTL_SECTIGO_ORG_ID`
|
||||||
|
2. Start certctl server — verify log line: `Sectigo SCM issuer registered`
|
||||||
|
3. Call `GET /api/v1/issuers` — verify `iss-sectigo` appears in the list
|
||||||
|
|
||||||
|
**PASS if** `iss-sectigo` registered and visible in API.
|
||||||
|
|
||||||
|
**43.M2: Enroll DV Certificate**
|
||||||
|
|
||||||
|
1. Create a certificate with `issuer_id: iss-sectigo`
|
||||||
|
2. Trigger issuance — verify enrollment submitted (job enters Pending or AwaitingCSR)
|
||||||
|
3. If DV, check for immediate issuance or poll via GetOrderStatus
|
||||||
|
4. Verify `sslId` tracked in job's order_id field
|
||||||
|
|
||||||
|
**PASS if** enrollment submits successfully, sslId returned, job state machine progresses.
|
||||||
|
|
||||||
|
**43.M3: Async Polling — OV Certificate**
|
||||||
|
|
||||||
|
1. Submit OV certificate enrollment (requires org validation)
|
||||||
|
2. Verify job enters Pending state with sslId in order_id
|
||||||
|
3. Wait for Sectigo to process (or mock status check)
|
||||||
|
4. Verify GetOrderStatus returns "pending" → "completed" transition
|
||||||
|
5. Verify PEM bundle downloaded and parsed (leaf + chain)
|
||||||
|
|
||||||
|
**PASS if** async flow works end-to-end with correct status transitions.
|
||||||
|
|
||||||
|
**43.M4: Collect Not Ready (400/-183 Handling)**
|
||||||
|
|
||||||
|
1. If possible, catch the window where status is "Issued" but cert not yet generated
|
||||||
|
2. Verify collect endpoint returns 400 with code -183
|
||||||
|
3. Verify GetOrderStatus treats this as "pending" (not error)
|
||||||
|
4. Verify next poll succeeds when cert is generated
|
||||||
|
|
||||||
|
**PASS if** 400/-183 handled gracefully as pending, not as error.
|
||||||
|
|
||||||
|
**43.M5: Revocation**
|
||||||
|
|
||||||
|
1. Revoke an issued Sectigo certificate via `POST /api/v1/certificates/{id}/revoke`
|
||||||
|
2. Verify Sectigo revoke endpoint called (`POST /ssl/v1/revoke/{sslId}`)
|
||||||
|
3. Verify audit trail records revocation
|
||||||
|
|
||||||
|
**PASS if** revocation recorded in certctl and sent to Sectigo.
|
||||||
|
|
||||||
|
**43.M6: Auth Header Verification**
|
||||||
|
|
||||||
|
1. Inspect network requests to Sectigo API (via proxy or logs)
|
||||||
|
2. Verify all 3 headers present: `customerUri`, `login`, `password`
|
||||||
|
3. Verify no `X-DC-DEVKEY` header (DigiCert auth should not leak)
|
||||||
|
|
||||||
|
**PASS if** correct 3-header auth on all requests.
|
||||||
|
|
||||||
### Summary
|
### Summary
|
||||||
|
|
||||||
| Category | Count |
|
| Category | Count |
|
||||||
|----------|-------|
|
|----------|-------|
|
||||||
| ☑ Auto (passed in `qa-smoke-test.sh`) | 144 |
|
| ☑ Auto (passed in `qa-smoke-test.sh`) | 144 |
|
||||||
| ☐ Auto (not yet run) | 12 |
|
| ☐ Auto (not yet run) | 20 |
|
||||||
| — Skipped (preconditions not met in demo) | 5 |
|
| — Skipped (preconditions not met in demo) | 5 |
|
||||||
| ☐ Manual (requires hands-on verification) | 241 |
|
| ☐ Manual (requires hands-on verification) | 247 |
|
||||||
| **Total** | **402** |
|
| **Total** | **416** |
|
||||||
|
|
||||||
**Automated tests must also be green.** CI passing is necessary but not sufficient — this manual QA catches integration issues that isolated unit tests miss.
|
**Automated tests must also be green.** CI passing is necessary but not sufficient — this manual QA catches integration issues that isolated unit tests miss.
|
||||||
|
|
||||||
|
|||||||
+75
-40
@@ -1,82 +1,117 @@
|
|||||||
# Why certctl?
|
# Why certctl?
|
||||||
|
|
||||||
Certificate management is broken at every scale between "one domain on Let's Encrypt" and "Fortune 500 budget for Venafi."
|
Certificate management is broken at every scale between "one domain on Let's Encrypt" and "Fortune 500 budget for Venafi." certctl fills that gap: a self-hosted platform that automates the entire certificate lifecycle, works with any CA, deploys to any server, and keeps private keys on your infrastructure. It's free, source-available, and you own everything.
|
||||||
|
|
||||||
If you run a personal blog, Certbot works fine. If your company spends $200K/year on Keyfactor, you're covered. But if you're an ops engineer managing 20-500 certificates across NGINX, Apache, HAProxy, and maybe a private CA — the tools available today either don't do enough or cost too much.
|
## The Math That Forces the Decision
|
||||||
|
|
||||||
certctl fills that gap.
|
The CA/Browser Forum passed [Ballot SC-081v3](https://cabforum.org/2025/04/11/ballot-sc081v3-introduce-schedule-of-reducing-validity-and-data-reuse-periods/) in April 2025, mandating a phased reduction in TLS certificate lifetimes: **200 days** as of March 2026, **100 days** by March 2027, and **47 days** by March 2029.
|
||||||
|
|
||||||
## The Problem
|
At 47-day lifespans, a team managing 100 certificates is processing **7+ renewals per week**, every week, forever. At 200 certificates, it's two per day. Manual processes, calendar reminders, and certbot cron jobs don't scale to this — a single missed renewal becomes a production outage at 3 AM. Certificate lifecycle automation is no longer optional; the only question is what tool runs it.
|
||||||
|
|
||||||
The CA/Browser Forum passed [Ballot SC-081v3](https://cabforum.org/2025/04/11/ballot-sc081v3-introduce-schedule-of-reducing-validity-and-data-reuse-periods/) in April 2025, mandating a phased reduction in TLS certificate lifetimes: 200 days as of March 2026, 100 days by March 2027, and 47 days by March 2029. That means every organization needs automated certificate renewal — not eventually, but now.
|
## The Landscape Today
|
||||||
|
|
||||||
The existing options for automation are:
|
If you're evaluating your options, here's what you'll find:
|
||||||
|
|
||||||
- **ACME clients** (Certbot, Lego, CertWarden): Handle issuance and renewal for ACME-compatible CAs, but don't manage deployment to target servers, don't provide inventory visibility, don't support non-ACME CAs, and don't offer audit trails or policy enforcement.
|
**ACME clients** (certbot, lego, acme.sh) handle issuance and renewal for Let's Encrypt and similar CAs, but they don't deploy to target servers, don't track inventory, don't support private CAs, and give you no audit trail or policy enforcement. You end up writing glue scripts and hoping they don't break.
|
||||||
- **Kubernetes-native** (cert-manager): Works well inside Kubernetes, but if your infrastructure includes bare-metal servers, VMs, or network appliances alongside Kubernetes, you need a separate solution for everything cert-manager can't reach.
|
|
||||||
- **Commercial SaaS** (CertKit, Sectigo CLM): Handle more of the lifecycle but are proprietary, cloud-dependent, and priced per certificate — costs scale linearly with your infrastructure.
|
**Kubernetes-native tools** (cert-manager) work well inside the cluster, but most organizations run mixed infrastructure — NGINX on VMs, HAProxy at the edge, IIS on Windows, maybe an F5. You need a separate solution for everything outside Kubernetes.
|
||||||
- **Enterprise platforms** (Venafi, Keyfactor, AppViewX): Comprehensive but start at $75K/year and require dedicated teams to operate.
|
|
||||||
|
**Commercial SaaS platforms** handle more of the lifecycle but are proprietary, cloud-dependent, and priced per certificate. At 100 certs and 20 agents, SaaS pricing runs $3,000-5,000/year and scales linearly. You're paying rent on your own infrastructure's security.
|
||||||
|
|
||||||
|
**Enterprise platforms** (Venafi, Keyfactor, AppViewX) are comprehensive but start at $75K/year and require dedicated teams to operate. If you have a 50-server environment, the licensing costs more than the servers.
|
||||||
|
|
||||||
## What certctl Does Differently
|
## What certctl Does Differently
|
||||||
|
|
||||||
certctl is a self-hosted certificate lifecycle platform. It handles issuance, renewal, deployment, revocation, discovery, and monitoring — with three design decisions that no other tool at any price point combines:
|
certctl handles issuance, renewal, deployment, revocation, discovery, and monitoring — with three design decisions that no other tool at any price point combines:
|
||||||
|
|
||||||
### 1. Private Keys Never Leave Your Infrastructure
|
### 1. Private Keys Never Leave Your Infrastructure
|
||||||
|
|
||||||
certctl agents generate private keys locally using ECDSA P-256. The agent creates a CSR and submits it to the control plane. The signed certificate comes back. The private key stays on the agent's filesystem with 0600 permissions.
|
certctl agents generate ECDSA P-256 private keys locally. The agent creates a CSR and submits it to the control plane. The signed certificate comes back. The private key stays on the agent's filesystem with 0600 permissions — it never crosses the network.
|
||||||
|
|
||||||
This isn't a premium feature — it's the default behavior in the free tier. Most competitors either generate keys server-side (creating a single point of compromise) or gate key isolation behind paid tiers.
|
This isn't a premium feature. It's the default behavior, free. Most alternatives either generate keys on the server (creating a single point of compromise) or gate key isolation behind paid tiers.
|
||||||
|
|
||||||
### 2. CA-Agnostic Issuer Architecture
|
### 2. CA-Agnostic Issuer Architecture
|
||||||
|
|
||||||
certctl works with any certificate authority, not just ACME providers:
|
certctl works with any certificate authority, not just ACME providers. Seven issuer connectors ship today, all free:
|
||||||
|
|
||||||
- **ACME** (Let's Encrypt, ZeroSSL, Google Trust Services, Buypass) — HTTP-01 and DNS-01 challenges, DNS-PERSIST-01 for zero-touch renewals, External Account Binding
|
- **ACME v2** (Let's Encrypt, ZeroSSL, Google Trust Services, Buypass) — HTTP-01, DNS-01, DNS-PERSIST-01 challenges, External Account Binding, ACME Renewal Information (RFC 9702)
|
||||||
- **step-ca** (Smallstep) — native /sign API with JWK provisioner authentication
|
- **HashiCorp Vault PKI** — `/v1/{mount}/sign/{role}` API, token auth
|
||||||
- **Local CA** — self-signed or sub-CA mode (chain to your enterprise root CA, e.g. ADCS)
|
- **DigiCert CertCentral** — async order model, OV/EV support
|
||||||
- **OpenSSL / Custom CA** — delegate signing to any shell script with configurable timeout
|
- **step-ca** (Smallstep) — native /sign API with JWK provisioner auth
|
||||||
- **EST enrollment** (RFC 7030) — device certificate enrollment for WiFi/802.1X, MDM, and IoT
|
- **Local CA** — self-signed or sub-CA mode (chain to ADCS or any enterprise root)
|
||||||
|
- **OpenSSL / Custom CA** — delegate signing to any shell script
|
||||||
|
- **EST enrollment** (RFC 7030) — device certs for WiFi/802.1X, MDM, IoT
|
||||||
|
|
||||||
Every issuer connector implements the same interface. Switching CAs or running multiple CAs in parallel requires zero code changes — just configuration.
|
Every connector implements the same interface. Running multiple CAs in parallel — Let's Encrypt for public certs, Vault for internal services, your enterprise CA for legacy systems — is configuration, not code.
|
||||||
|
|
||||||
### 3. Post-Deployment Verification
|
### 3. Post-Deployment Verification
|
||||||
|
|
||||||
Every other tool in this space stops at "the deployment command succeeded." certctl goes further: after deploying a certificate to a target, the agent connects back to the target's TLS endpoint and verifies the served certificate matches what was deployed, using SHA-256 fingerprint comparison.
|
Every other tool in this space stops at "the deployment command succeeded." certctl goes further: after deploying a certificate, the agent connects back to the live TLS endpoint and compares the SHA-256 fingerprint of the served certificate against what was deployed.
|
||||||
|
|
||||||
A reload command can exit 0 while the certificate doesn't take effect — wrong virtual host, stale cache, config that validates but doesn't apply. certctl catches this.
|
A reload command can exit 0 while the certificate doesn't take effect — wrong virtual host, stale cache, config that validates but doesn't apply. certctl catches this automatically.
|
||||||
|
|
||||||
|
## What Else Ships Free
|
||||||
|
|
||||||
|
The three differentiators above get the headlines, but the feature surface is wider than most paid platforms:
|
||||||
|
|
||||||
|
**10 deployment targets** — NGINX, Apache, HAProxy, Traefik, Caddy, Envoy, IIS (local PowerShell + remote WinRM), Postfix, and Dovecot. All use a pluggable connector model. The control plane never initiates outbound connections — agents poll for work, meaning certctl works behind firewalls, across network zones, and in air-gapped environments.
|
||||||
|
|
||||||
|
**Network certificate discovery** — active TLS scanning of CIDR ranges finds certificates you didn't know existed. Agents also scan local filesystems for PEM/DER files. Everything feeds into a triage workflow where you claim, dismiss, or import discovered certs into management.
|
||||||
|
|
||||||
|
**Immutable audit trail** — every API call recorded (method, path, actor, body hash, status, latency). Every certificate lifecycle event tracked. Append-only, no update or delete. Mapped to SOC 2, PCI-DSS 4.0, and NIST SP 800-57 compliance frameworks with published evidence guides.
|
||||||
|
|
||||||
|
**Policy engine** — 5 rule types (allowed issuers, allowed domains, required metadata, allowed environments, renewal lead time) with violation tracking and severity levels.
|
||||||
|
|
||||||
|
**PKI compliance** — DER-encoded X.509 CRL signed by issuing CA, embedded OCSP responder, RFC 5280 revocation with all reason codes, short-lived certificate exemption.
|
||||||
|
|
||||||
|
**Prometheus metrics** — `/api/v1/metrics/prometheus` in standard exposition format. Works with Prometheus, Grafana Agent, Datadog Agent, Victoria Metrics.
|
||||||
|
|
||||||
|
**MCP server** — 80 tools exposing the entire API surface for AI-assisted certificate management via Claude, Cursor, or any MCP-compatible client. No other certificate platform offers this.
|
||||||
|
|
||||||
|
**Full REST API** — 97 OpenAPI 3.1-documented operations. CLI tool with 10 subcommands. Helm chart for Kubernetes deployment. Scheduled certificate digest emails. Certificate export in PEM and PKCS#12. S/MIME support with EKU-aware issuance.
|
||||||
|
|
||||||
|
**1,554 tests** — Go backend with race detection, static analysis (golangci-lint), and vulnerability scanning (govulncheck) on every commit. Frontend test suite. CI runs on every push.
|
||||||
|
|
||||||
## How certctl Compares
|
## How certctl Compares
|
||||||
|
|
||||||
### vs. CertKit
|
### vs. ACME Clients
|
||||||
|
|
||||||
Closest competitor architecturally — agent-based, private key isolation (Keystore), multi-platform. certctl leads on issuer coverage (ACME + step-ca + Local CA + OpenSSL + EST vs. ACME-only), PKI compliance (CRL, OCSP, RFC 5280 revocation, immutable audit trail — all missing from CertKit today), policy engine (5 rule types vs. none), and network discovery (CIDR TLS scanning vs. none). certctl is source-available (BSL 1.1 → Apache 2.0) with no cert limit; CertKit is proprietary SaaS with a 3-cert free tier. Where CertKit leads: more deployment targets today (adds LiteSpeed, IIS, auto-detection), Windows support, Kubernetes, and polished SaaS onboarding.
|
ACME clients solve one slice of the problem — issuance and renewal from ACME CAs. certctl replaces the ACME client, adds 6 more CA integrations, deploys the cert to the right server, verifies it's live, tracks it in an inventory, alerts on expiry, logs everything to an audit trail, and enforces policy. If you're currently running certbot behind a cron job and a prayer, certctl replaces all of it.
|
||||||
|
|
||||||
### vs. KeyTalk
|
### vs. Agent-Based SaaS
|
||||||
|
|
||||||
Commercial (proprietary) PKI platform from a Dutch company — on-prem appliance, cloud, or managed service. Broader cert type coverage (TLS, S/MIME, device auth, VPN) and DigiCert + SCEP integrations. No public documentation on policy engine, API surface, or audit capabilities. No free tier, no public pricing. certctl trades breadth of cert types for full transparency — source-available, public API spec, free community edition with no limits.
|
The closest architectural competitors use the same agent model — local key generation, CSR submission, push-based deployment. Where certctl differs: it supports 7 issuer types (not just ACME), provides CRL/OCSP/revocation infrastructure (not just issuance), includes a policy engine and network discovery, and is source-available with no certificate limit. SaaS alternatives are typically proprietary, priced per certificate ($2+/cert/month), and cap their free tiers at 3-5 certificates. certctl is free for any number of certificates, forever.
|
||||||
|
|
||||||
### vs. Enterprise Platforms (Venafi, Keyfactor)
|
### vs. Commercial PKI Platforms
|
||||||
|
|
||||||
Comprehensive solutions with decades of features — at $75K-$250K+/yr. certctl targets organizations that need 80% of those capabilities at 1% of the cost. The trade-off: no SSO/RBAC yet (coming in certctl Pro), no F5/IIS target connectors yet, no SLA-backed support.
|
On-prem or hosted commercial platforms offer broader cert type coverage (VPN certs, device auth, SCEP) and deeper CA integrations. The trade-off: no free tier, opaque pricing (often €13K+/year for 1,500 certs), proprietary codebases, and no public API documentation. certctl trades breadth of exotic cert types for full transparency — source-available code, 97-operation OpenAPI spec, and a free community edition with no artificial limits.
|
||||||
|
|
||||||
## Getting Started
|
### vs. Enterprise Platforms
|
||||||
|
|
||||||
|
Venafi and Keyfactor offer decades of features at $75K-$250K+/year. certctl targets organizations that need 80% of those capabilities at a fraction of the cost. What certctl doesn't have yet: SSO/RBAC (coming in certctl Pro), vendor SLA-backed support. What certctl does have that enterprise platforms don't: an MCP server for AI-assisted management, ACME ARI (RFC 9702) for CA-directed renewal timing, and a deployment model that works in 5 minutes instead of 5 months.
|
||||||
|
|
||||||
|
## Who Should Look Elsewhere
|
||||||
|
|
||||||
|
certctl isn't the right tool for everyone:
|
||||||
|
|
||||||
|
- **Single-domain sites** — if you have one certificate on one server, certbot is fine. certctl is designed for managing tens to hundreds of certificates across multiple servers and CAs.
|
||||||
|
- **Pure Kubernetes environments** — if every workload runs in-cluster and you're happy with cert-manager, there's no reason to add another tool. certctl shines when your infrastructure extends beyond Kubernetes.
|
||||||
|
- **Organizations that need a vendor SLA today** — certctl is source-available software maintained by a small team. If you need contractual uptime guarantees and a support hotline, an enterprise platform is the right choice (for now).
|
||||||
|
|
||||||
|
## See It Running
|
||||||
|
|
||||||
|
The demo seeds 32 certificates across 7 issuers, 8 agents, 6 deployment targets, and 180 days of realistic history — jobs, audit events, discovery scans, approval workflows — so you can explore every feature immediately.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone and start with Docker Compose (includes demo data)
|
|
||||||
git clone https://github.com/shankar0123/certctl.git
|
git clone https://github.com/shankar0123/certctl.git
|
||||||
cd certctl/deploy
|
cd certctl/deploy && docker compose up -d
|
||||||
docker compose up -d
|
# Dashboard at http://localhost:8443
|
||||||
|
|
||||||
# Open the dashboard
|
|
||||||
open http://localhost:8443
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The demo seeds 35 certificates across 5 issuers, 8 agents, 8 deployment targets, 90 days of job history, discovery scan data, network scan targets, and pending approval jobs so you can explore every feature immediately.
|
See the [Quickstart Guide](quickstart.md) for a full walkthrough, or explore the [5 turnkey examples](../examples/) for specific scenarios (ACME+NGINX, wildcard DNS-01, private CA+Traefik, step-ca+HAProxy, multi-issuer).
|
||||||
|
|
||||||
See the [Quickstart Guide](quickstart.md) for a full walkthrough.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
certctl is licensed under the [Business Source License 1.1](../LICENSE). The licensed work is free to use for any purpose other than offering a competing managed service. The license converts to Apache 2.0 on March 1, 2033.
|
certctl is source-available under the [Business Source License 1.1](../LICENSE). Free for any use except offering a competing managed service. Converts to Apache 2.0 on March 1, 2033.
|
||||||
|
|
||||||
The source is available, auditable, and self-hostable. You own your data, your keys, and your deployment.
|
You own your data, your keys, and your deployment.
|
||||||
|
|||||||
@@ -13,16 +13,18 @@ This example demonstrates certctl's core use case: **automatically manage TLS ce
|
|||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
```
|
```mermaid
|
||||||
Your Domain (example.com)
|
flowchart TD
|
||||||
↓ [HTTP-01 validation, port 80]
|
A["Your Domain (example.com)"]
|
||||||
Let's Encrypt ACME
|
B["Let's Encrypt ACME"]
|
||||||
↓ [CSR submission]
|
C["certctl Server (control plane)"]
|
||||||
certctl Server (control plane)
|
D["certctl Agent (on NGINX server)"]
|
||||||
↓ [API polling]
|
E["NGINX Reverse Proxy"]
|
||||||
certctl Agent (on NGINX server)
|
|
||||||
↓ [deploy cert+key]
|
A -->|HTTP-01 validation<br/>port 80| B
|
||||||
NGINX Reverse Proxy
|
B -->|CSR submission| C
|
||||||
|
C -->|API polling| D
|
||||||
|
D -->|deploy cert+key| E
|
||||||
```
|
```
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ services:
|
|||||||
container_name: certctl-server-acme-nginx
|
container_name: certctl-server-acme-nginx
|
||||||
environment:
|
environment:
|
||||||
# Database
|
# Database
|
||||||
DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
CERTCTL_DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
||||||
|
|
||||||
# Server settings
|
# Server settings
|
||||||
CERTCTL_SERVER_PORT: 8443
|
CERTCTL_SERVER_PORT: 8443
|
||||||
@@ -61,7 +61,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- certctl-network
|
- certctl-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/api/v1/health || exit 1']
|
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/health || exit 1']
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ services:
|
|||||||
container_name: certctl-server-dns01
|
container_name: certctl-server-dns01
|
||||||
environment:
|
environment:
|
||||||
# Database
|
# Database
|
||||||
DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
CERTCTL_DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
||||||
|
|
||||||
# Server settings
|
# Server settings
|
||||||
CERTCTL_SERVER_PORT: 8443
|
CERTCTL_SERVER_PORT: 8443
|
||||||
@@ -113,7 +113,7 @@ services:
|
|||||||
- certctl-network
|
- certctl-network
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/api/v1/health || exit 1']
|
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/health || exit 1']
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ services:
|
|||||||
container_name: certctl-server-multi-issuer
|
container_name: certctl-server-multi-issuer
|
||||||
environment:
|
environment:
|
||||||
# Database
|
# Database
|
||||||
DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
CERTCTL_DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
||||||
|
|
||||||
# Server settings
|
# Server settings
|
||||||
CERTCTL_SERVER_PORT: 8443
|
CERTCTL_SERVER_PORT: 8443
|
||||||
@@ -64,7 +64,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- certctl-network
|
- certctl-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/api/v1/health || exit 1']
|
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/health || exit 1']
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -13,27 +13,29 @@ With certctl, both issuer types are configured and available. You assign each ce
|
|||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
```
|
```mermaid
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
flowchart TD
|
||||||
│ certctl Server (Control Plane) │
|
subgraph Server ["certctl Server (Control Plane)"]
|
||||||
│ - Let's Encrypt ACME issuer (HTTP-01 challenges) │
|
A["Let's Encrypt ACME issuer<br/>(HTTP-01 challenges)"]
|
||||||
│ - Local CA issuer (self-signed or sub-CA mode) │
|
B["Local CA issuer<br/>(self-signed or sub-CA mode)"]
|
||||||
│ - PostgreSQL database (cert inventory, audit, jobs) │
|
C["PostgreSQL database<br/>(cert inventory, audit, jobs)"]
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
end
|
||||||
▲
|
|
||||||
│ API polling
|
subgraph Agent ["certctl Agent"]
|
||||||
│
|
D["Discovers existing certs<br/>(/etc/nginx/ssl, /etc/app/ssl)"]
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
E["Polls server for<br/>renewal/issuance/deployment jobs"]
|
||||||
│ certctl Agent │
|
F["Generates keys locally<br/>(agent-side crypto)"]
|
||||||
│ - Discovers existing certs in /etc/nginx/ssl and /etc/app/ssl │
|
G["Deploys certs to NGINX<br/>and app service directories"]
|
||||||
│ - Polls server for renewal/issuance/deployment jobs │
|
end
|
||||||
│ - Generates keys locally (agent-side crypto) │
|
|
||||||
│ - Deploys certs to NGINX and app service directories │
|
subgraph Targets ["Target Services"]
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
H["NGINX (public TLS)<br/>(Let's Encrypt certs)"]
|
||||||
│ │
|
I["App Services (internal TLS)<br/>(Local CA certs)"]
|
||||||
▼ ▼
|
end
|
||||||
NGINX (public TLS) App Services (internal TLS)
|
|
||||||
(Let's Encrypt certs) (Local CA certs)
|
Server -->|API polling| Agent
|
||||||
|
Agent -->|Deploy| H
|
||||||
|
Agent -->|Deploy| I
|
||||||
```
|
```
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
@@ -212,7 +214,7 @@ Each agent independently manages its local cert inventory and deployments. The s
|
|||||||
- For ACME, ensure ports 80/443 are open and your domain resolves
|
- For ACME, ensure ports 80/443 are open and your domain resolves
|
||||||
|
|
||||||
### Agent can't reach server
|
### Agent can't reach server
|
||||||
- Check network: `docker compose exec certctl-agent curl http://certctl-server:8443/api/v1/health`
|
- Check network: `docker compose exec certctl-agent curl http://certctl-server:8443/health`
|
||||||
- Verify `CERTCTL_SERVER_URL` environment variable
|
- Verify `CERTCTL_SERVER_URL` environment variable
|
||||||
|
|
||||||
### No issuers showing up
|
### No issuers showing up
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ services:
|
|||||||
container_name: certctl-server-private-ca
|
container_name: certctl-server-private-ca
|
||||||
environment:
|
environment:
|
||||||
# Database
|
# Database
|
||||||
DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
CERTCTL_DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
||||||
|
|
||||||
# Server settings
|
# Server settings
|
||||||
CERTCTL_SERVER_PORT: 8443
|
CERTCTL_SERVER_PORT: 8443
|
||||||
@@ -77,7 +77,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- certctl-network
|
- certctl-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/api/v1/health || exit 1']
|
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/health || exit 1']
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -17,29 +17,16 @@ This example demonstrates certctl managing certificates for **internal services
|
|||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
```
|
```mermaid
|
||||||
┌──────────────────┐
|
flowchart TD
|
||||||
│ certctl-server │ (Local CA issuer)
|
A["certctl-server<br/>(control plane)<br/>(Local CA issuer)"]
|
||||||
│ (control │
|
B["certctl-agent<br/>(certificate deployer)"]
|
||||||
│ plane) │
|
C["Traefik<br/>(watches cert directory)"]
|
||||||
└────────┬─────────┘
|
D["[Internal Services]"]
|
||||||
│
|
|
||||||
│ REST API (job polling)
|
A -->|REST API<br/>job polling| B
|
||||||
│
|
B -->|Write cert/key files| C
|
||||||
┌────────▼──────────┐
|
C -->|TLS handshakes| D
|
||||||
│ certctl-agent │ (certificate deployer)
|
|
||||||
└────────┬──────────┘
|
|
||||||
│
|
|
||||||
│ Write cert/key files
|
|
||||||
│
|
|
||||||
┌────────▼──────────────────────┐
|
|
||||||
│ Traefik │
|
|
||||||
│ (watches cert directory) │
|
|
||||||
└────────────────────────────────┘
|
|
||||||
│
|
|
||||||
│ TLS handshakes
|
|
||||||
│
|
|
||||||
[Internal Services]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start (Self-Signed CA)
|
## Quick Start (Self-Signed CA)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ services:
|
|||||||
container_name: certctl-server-stepca-haproxy
|
container_name: certctl-server-stepca-haproxy
|
||||||
environment:
|
environment:
|
||||||
# Database
|
# Database
|
||||||
DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
CERTCTL_DATABASE_URL: postgres://certctl:${DB_PASSWORD:-certctl-dev-password}@postgres:5432/certctl?sslmode=disable
|
||||||
|
|
||||||
# Server settings
|
# Server settings
|
||||||
CERTCTL_SERVER_PORT: 8443
|
CERTCTL_SERVER_PORT: 8443
|
||||||
@@ -119,7 +119,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- certctl-network
|
- certctl-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/api/v1/health || exit 1']
|
test: ['CMD-SHELL', 'curl -sf http://localhost:8443/health || exit 1']
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ Common issues:
|
|||||||
Verify network:
|
Verify network:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose exec certctl-agent curl http://certctl-server:8443/api/v1/health
|
docker compose exec certctl-agent curl http://certctl-server:8443/health
|
||||||
```
|
```
|
||||||
|
|
||||||
### HAProxy config validation fails
|
### HAProxy config validation fails
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type Config struct {
|
|||||||
ACME ACMEConfig
|
ACME ACMEConfig
|
||||||
Vault VaultConfig
|
Vault VaultConfig
|
||||||
DigiCert DigiCertConfig
|
DigiCert DigiCertConfig
|
||||||
|
Sectigo SectigoConfig
|
||||||
Digest DigestConfig
|
Digest DigestConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +195,43 @@ type DigiCertConfig struct {
|
|||||||
BaseURL string
|
BaseURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SectigoConfig contains Sectigo Certificate Manager issuer connector configuration.
|
||||||
|
type SectigoConfig struct {
|
||||||
|
// CustomerURI is the Sectigo customer URI (organization identifier).
|
||||||
|
// Required for Sectigo integration.
|
||||||
|
// Setting: CERTCTL_SECTIGO_CUSTOMER_URI environment variable.
|
||||||
|
CustomerURI string
|
||||||
|
|
||||||
|
// Login is the Sectigo API account login.
|
||||||
|
// Required for Sectigo integration.
|
||||||
|
// Setting: CERTCTL_SECTIGO_LOGIN environment variable.
|
||||||
|
Login string
|
||||||
|
|
||||||
|
// Password is the Sectigo API account password or API key.
|
||||||
|
// Required for Sectigo integration.
|
||||||
|
// Setting: CERTCTL_SECTIGO_PASSWORD environment variable.
|
||||||
|
Password string
|
||||||
|
|
||||||
|
// OrgID is the Sectigo organization ID for certificate enrollments.
|
||||||
|
// Required for Sectigo integration.
|
||||||
|
// Setting: CERTCTL_SECTIGO_ORG_ID environment variable.
|
||||||
|
OrgID int
|
||||||
|
|
||||||
|
// CertType is the Sectigo certificate type ID (from GET /ssl/v1/types).
|
||||||
|
// Required for enrollment. Set via CERTCTL_SECTIGO_CERT_TYPE environment variable.
|
||||||
|
CertType int
|
||||||
|
|
||||||
|
// Term is the certificate validity in days (e.g., 365, 730).
|
||||||
|
// Default: 365.
|
||||||
|
// Setting: CERTCTL_SECTIGO_TERM environment variable.
|
||||||
|
Term int
|
||||||
|
|
||||||
|
// BaseURL is the Sectigo SCM API base URL.
|
||||||
|
// Default: "https://cert-manager.com/api".
|
||||||
|
// Setting: CERTCTL_SECTIGO_BASE_URL environment variable.
|
||||||
|
BaseURL string
|
||||||
|
}
|
||||||
|
|
||||||
// DigestConfig controls the scheduled certificate digest email feature.
|
// DigestConfig controls the scheduled certificate digest email feature.
|
||||||
type DigestConfig struct {
|
type DigestConfig struct {
|
||||||
// Enabled controls whether periodic digest emails are generated and sent.
|
// Enabled controls whether periodic digest emails are generated and sent.
|
||||||
@@ -500,6 +538,15 @@ func Load() (*Config, error) {
|
|||||||
ProductType: getEnv("CERTCTL_DIGICERT_PRODUCT_TYPE", "ssl_basic"),
|
ProductType: getEnv("CERTCTL_DIGICERT_PRODUCT_TYPE", "ssl_basic"),
|
||||||
BaseURL: getEnv("CERTCTL_DIGICERT_BASE_URL", "https://www.digicert.com/services/v2"),
|
BaseURL: getEnv("CERTCTL_DIGICERT_BASE_URL", "https://www.digicert.com/services/v2"),
|
||||||
},
|
},
|
||||||
|
Sectigo: SectigoConfig{
|
||||||
|
CustomerURI: getEnv("CERTCTL_SECTIGO_CUSTOMER_URI", ""),
|
||||||
|
Login: getEnv("CERTCTL_SECTIGO_LOGIN", ""),
|
||||||
|
Password: getEnv("CERTCTL_SECTIGO_PASSWORD", ""),
|
||||||
|
OrgID: getEnvInt("CERTCTL_SECTIGO_ORG_ID", 0),
|
||||||
|
CertType: getEnvInt("CERTCTL_SECTIGO_CERT_TYPE", 0),
|
||||||
|
Term: getEnvInt("CERTCTL_SECTIGO_TERM", 365),
|
||||||
|
BaseURL: getEnv("CERTCTL_SECTIGO_BASE_URL", "https://cert-manager.com/api"),
|
||||||
|
},
|
||||||
ACME: ACMEConfig{
|
ACME: ACMEConfig{
|
||||||
DirectoryURL: getEnv("CERTCTL_ACME_DIRECTORY_URL", ""),
|
DirectoryURL: getEnv("CERTCTL_ACME_DIRECTORY_URL", ""),
|
||||||
Email: getEnv("CERTCTL_ACME_EMAIL", ""),
|
Email: getEnv("CERTCTL_ACME_EMAIL", ""),
|
||||||
|
|||||||
@@ -0,0 +1,618 @@
|
|||||||
|
// Package sectigo implements the issuer.Connector interface for Sectigo Certificate Manager (SCM).
|
||||||
|
//
|
||||||
|
// Sectigo Certificate Manager is an enterprise certificate authority offering DV, OV, and EV
|
||||||
|
// certificates. Like DigiCert, Sectigo uses an asynchronous order model: submit an enrollment,
|
||||||
|
// receive an sslId, then poll for completion. OV/EV certificates require organization validation
|
||||||
|
// which may take hours or days; DV certificates may be issued immediately.
|
||||||
|
//
|
||||||
|
// This connector maps to certctl's existing job state machine:
|
||||||
|
// - IssueCertificate submits the enrollment; if status is "Issued", returns cert immediately.
|
||||||
|
// If status is "Applied" or "Pending", returns OrderID with empty CertPEM — the job system
|
||||||
|
// polls via GetOrderStatus.
|
||||||
|
// - GetOrderStatus polls the order; when status becomes "Issued", downloads and parses the
|
||||||
|
// PEM bundle via the collect endpoint.
|
||||||
|
//
|
||||||
|
// Authentication: Three custom headers on every request — customerUri, login, password.
|
||||||
|
//
|
||||||
|
// Sectigo SCM REST API used:
|
||||||
|
//
|
||||||
|
// POST /ssl/v1/enroll - Submit certificate enrollment
|
||||||
|
// GET /ssl/v1/{sslId} - Check enrollment status
|
||||||
|
// GET /ssl/v1/collect/{sslId}/pem - Download PEM bundle when issued
|
||||||
|
// POST /ssl/v1/revoke/{sslId} - Revoke certificate
|
||||||
|
// GET /ssl/v1/types - List available cert types (used for health check)
|
||||||
|
package sectigo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/json"
|
||||||
|
"encoding/pem"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log/slog"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/shankar0123/certctl/internal/connector/issuer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config represents the Sectigo Certificate Manager issuer connector configuration.
|
||||||
|
type Config struct {
|
||||||
|
// CustomerURI is the Sectigo customer URI (organization identifier).
|
||||||
|
// Required. Set via CERTCTL_SECTIGO_CUSTOMER_URI environment variable.
|
||||||
|
CustomerURI string `json:"customer_uri"`
|
||||||
|
|
||||||
|
// Login is the Sectigo API account login.
|
||||||
|
// Required. Set via CERTCTL_SECTIGO_LOGIN environment variable.
|
||||||
|
Login string `json:"login"`
|
||||||
|
|
||||||
|
// Password is the Sectigo API account password or API key.
|
||||||
|
// Required. Set via CERTCTL_SECTIGO_PASSWORD environment variable.
|
||||||
|
Password string `json:"password"`
|
||||||
|
|
||||||
|
// OrgID is the Sectigo organization ID for certificate enrollments.
|
||||||
|
// Required. Set via CERTCTL_SECTIGO_ORG_ID environment variable.
|
||||||
|
OrgID int `json:"org_id"`
|
||||||
|
|
||||||
|
// CertType is the Sectigo certificate type ID (from GET /ssl/v1/types).
|
||||||
|
// Required for enrollment. Set via CERTCTL_SECTIGO_CERT_TYPE environment variable.
|
||||||
|
CertType int `json:"cert_type"`
|
||||||
|
|
||||||
|
// Term is the certificate validity in days (e.g., 365, 730).
|
||||||
|
// Default: 365. Set via CERTCTL_SECTIGO_TERM environment variable.
|
||||||
|
Term int `json:"term"`
|
||||||
|
|
||||||
|
// BaseURL is the Sectigo SCM API base URL.
|
||||||
|
// Default: "https://cert-manager.com/api".
|
||||||
|
// Set via CERTCTL_SECTIGO_BASE_URL environment variable.
|
||||||
|
BaseURL string `json:"base_url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connector implements the issuer.Connector interface for Sectigo Certificate Manager.
|
||||||
|
type Connector struct {
|
||||||
|
config *Config
|
||||||
|
logger *slog.Logger
|
||||||
|
httpClient *http.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new Sectigo SCM connector with the given configuration and logger.
|
||||||
|
func New(config *Config, logger *slog.Logger) *Connector {
|
||||||
|
if config != nil {
|
||||||
|
if config.Term == 0 {
|
||||||
|
config.Term = 365
|
||||||
|
}
|
||||||
|
if config.BaseURL == "" {
|
||||||
|
config.BaseURL = "https://cert-manager.com/api"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Connector{
|
||||||
|
config: config,
|
||||||
|
logger: logger,
|
||||||
|
httpClient: &http.Client{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// enrollRequest is the JSON body for Sectigo certificate enrollment.
|
||||||
|
type enrollRequest struct {
|
||||||
|
OrgID int `json:"orgId"`
|
||||||
|
CSR string `json:"csr"`
|
||||||
|
CertType int `json:"certType"`
|
||||||
|
Term int `json:"term"`
|
||||||
|
SubjAltNames string `json:"subjAltNames,omitempty"`
|
||||||
|
Comments string `json:"comments,omitempty"`
|
||||||
|
ExternalRequester string `json:"externalRequester,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// enrollResponse is the JSON response from a certificate enrollment.
|
||||||
|
type enrollResponse struct {
|
||||||
|
SSLId int `json:"sslId"`
|
||||||
|
RenewId string `json:"renewId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// statusResponse is the JSON response from an enrollment status check.
|
||||||
|
type statusResponse struct {
|
||||||
|
SSLId int `json:"sslId"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
CommonName string `json:"commonName,omitempty"`
|
||||||
|
SerialNumber string `json:"serialNumber,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// setAuthHeaders sets the three Sectigo authentication headers on a request.
|
||||||
|
func (c *Connector) setAuthHeaders(req *http.Request) {
|
||||||
|
req.Header.Set("customerUri", c.config.CustomerURI)
|
||||||
|
req.Header.Set("login", c.config.Login)
|
||||||
|
req.Header.Set("password", c.config.Password)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateConfig checks that the Sectigo configuration is valid and API access works.
|
||||||
|
func (c *Connector) ValidateConfig(ctx context.Context, rawConfig json.RawMessage) error {
|
||||||
|
var cfg Config
|
||||||
|
if err := json.Unmarshal(rawConfig, &cfg); err != nil {
|
||||||
|
return fmt.Errorf("invalid Sectigo config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.CustomerURI == "" {
|
||||||
|
return fmt.Errorf("Sectigo customer_uri is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Login == "" {
|
||||||
|
return fmt.Errorf("Sectigo login is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Password == "" {
|
||||||
|
return fmt.Errorf("Sectigo password is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.OrgID == 0 {
|
||||||
|
return fmt.Errorf("Sectigo org_id is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Term == 0 {
|
||||||
|
cfg.Term = 365
|
||||||
|
}
|
||||||
|
if cfg.BaseURL == "" {
|
||||||
|
cfg.BaseURL = "https://cert-manager.com/api"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test API access via GET /ssl/v1/types (health check)
|
||||||
|
typesURL := cfg.BaseURL + "/ssl/v1/types"
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, typesURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create API test request: %w", err)
|
||||||
|
}
|
||||||
|
req.Header.Set("customerUri", cfg.CustomerURI)
|
||||||
|
req.Header.Set("login", cfg.Login)
|
||||||
|
req.Header.Set("password", cfg.Password)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
resp, err := c.httpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Sectigo API not reachable at %s: %w", cfg.BaseURL, err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusUnauthorized {
|
||||||
|
return fmt.Errorf("Sectigo API credentials are invalid (status %d)", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return fmt.Errorf("Sectigo API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.config = &cfg
|
||||||
|
c.logger.Info("Sectigo Certificate Manager configuration validated",
|
||||||
|
"base_url", cfg.BaseURL,
|
||||||
|
"org_id", cfg.OrgID)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueCertificate submits a certificate enrollment to Sectigo SCM.
|
||||||
|
// If the certificate is issued immediately (DV certs), returns the cert.
|
||||||
|
// If pending (OV/EV certs), returns OrderID with empty CertPEM for polling.
|
||||||
|
func (c *Connector) IssueCertificate(ctx context.Context, request issuer.IssuanceRequest) (*issuer.IssuanceResult, error) {
|
||||||
|
c.logger.Info("processing Sectigo enrollment request",
|
||||||
|
"common_name", request.CommonName,
|
||||||
|
"san_count", len(request.SANs),
|
||||||
|
"cert_type", c.config.CertType)
|
||||||
|
|
||||||
|
enrollReq := enrollRequest{
|
||||||
|
OrgID: c.config.OrgID,
|
||||||
|
CSR: request.CSRPEM,
|
||||||
|
CertType: c.config.CertType,
|
||||||
|
Term: c.config.Term,
|
||||||
|
Comments: "Issued by certctl",
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(request.SANs) > 0 {
|
||||||
|
enrollReq.SubjAltNames = strings.Join(request.SANs, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := json.Marshal(enrollReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to marshal enrollment request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
enrollURL := c.config.BaseURL + "/ssl/v1/enroll"
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, enrollURL, bytes.NewReader(body))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create enrollment request: %w", err)
|
||||||
|
}
|
||||||
|
c.setAuthHeaders(req)
|
||||||
|
|
||||||
|
resp, err := c.httpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Sectigo enrollment request failed: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
respBody, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to read enrollment response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
||||||
|
return nil, fmt.Errorf("Sectigo enrollment returned status %d: %s", resp.StatusCode, string(respBody))
|
||||||
|
}
|
||||||
|
|
||||||
|
var enrollResp enrollResponse
|
||||||
|
if err := json.Unmarshal(respBody, &enrollResp); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to parse enrollment response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
orderID := fmt.Sprintf("%d", enrollResp.SSLId)
|
||||||
|
|
||||||
|
c.logger.Info("Sectigo enrollment submitted", "ssl_id", orderID)
|
||||||
|
|
||||||
|
// Check status immediately to see if cert was issued right away
|
||||||
|
status, err := c.checkStatus(ctx, enrollResp.SSLId)
|
||||||
|
if err != nil {
|
||||||
|
// Status check failed but enrollment succeeded — return as pending
|
||||||
|
c.logger.Warn("Sectigo status check after enrollment failed, treating as pending",
|
||||||
|
"ssl_id", orderID, "error", err)
|
||||||
|
return &issuer.IssuanceResult{
|
||||||
|
OrderID: orderID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if status.Status == "Issued" {
|
||||||
|
certPEM, chainPEM, serial, notBefore, notAfter, collectErr := c.collectCertificate(ctx, enrollResp.SSLId)
|
||||||
|
if collectErr != nil {
|
||||||
|
// Cert is issued but collect failed — might not be generated yet
|
||||||
|
c.logger.Warn("Sectigo certificate issued but collect failed, treating as pending",
|
||||||
|
"ssl_id", orderID, "error", collectErr)
|
||||||
|
return &issuer.IssuanceResult{
|
||||||
|
OrderID: orderID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c.logger.Info("Sectigo certificate issued immediately",
|
||||||
|
"ssl_id", orderID,
|
||||||
|
"serial", serial)
|
||||||
|
|
||||||
|
return &issuer.IssuanceResult{
|
||||||
|
CertPEM: certPEM,
|
||||||
|
ChainPEM: chainPEM,
|
||||||
|
Serial: serial,
|
||||||
|
NotBefore: notBefore,
|
||||||
|
NotAfter: notAfter,
|
||||||
|
OrderID: orderID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pending — return OrderID for polling via GetOrderStatus
|
||||||
|
c.logger.Info("Sectigo enrollment pending validation",
|
||||||
|
"ssl_id", orderID,
|
||||||
|
"status", status.Status)
|
||||||
|
|
||||||
|
return &issuer.IssuanceResult{
|
||||||
|
OrderID: orderID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenewCertificate renews a certificate by submitting a new enrollment.
|
||||||
|
// Sectigo supports POST /ssl/renewById/{sslId} but for simplicity we submit
|
||||||
|
// a new enrollment (same pattern as DigiCert).
|
||||||
|
func (c *Connector) RenewCertificate(ctx context.Context, request issuer.RenewalRequest) (*issuer.IssuanceResult, error) {
|
||||||
|
c.logger.Info("processing Sectigo renewal request",
|
||||||
|
"common_name", request.CommonName,
|
||||||
|
"san_count", len(request.SANs))
|
||||||
|
|
||||||
|
return c.IssueCertificate(ctx, issuer.IssuanceRequest{
|
||||||
|
CommonName: request.CommonName,
|
||||||
|
SANs: request.SANs,
|
||||||
|
CSRPEM: request.CSRPEM,
|
||||||
|
EKUs: request.EKUs,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeCertificate revokes a certificate at Sectigo SCM.
|
||||||
|
func (c *Connector) RevokeCertificate(ctx context.Context, request issuer.RevocationRequest) error {
|
||||||
|
c.logger.Info("processing Sectigo revocation request", "serial", request.Serial)
|
||||||
|
|
||||||
|
reason := "Unspecified"
|
||||||
|
if request.Reason != nil {
|
||||||
|
reason = mapRevocationReason(*request.Reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
revokeBody := map[string]interface{}{
|
||||||
|
"reason": reason,
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := json.Marshal(revokeBody)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to marshal revoke request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sectigo uses sslId in the URL path for revocation
|
||||||
|
revokeURL := fmt.Sprintf("%s/ssl/v1/revoke/%s", c.config.BaseURL, request.Serial)
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, revokeURL, bytes.NewReader(body))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create revoke request: %w", err)
|
||||||
|
}
|
||||||
|
c.setAuthHeaders(req)
|
||||||
|
|
||||||
|
resp, err := c.httpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Sectigo revoke request failed: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Sectigo returns 204 No Content on successful revocation
|
||||||
|
if resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusOK {
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
return fmt.Errorf("Sectigo revoke returned status %d: %s", resp.StatusCode, string(respBody))
|
||||||
|
}
|
||||||
|
|
||||||
|
c.logger.Info("Sectigo certificate revoked", "serial", request.Serial, "reason", reason)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrderStatus checks the status of a Sectigo certificate enrollment.
|
||||||
|
// If the enrollment is "Issued", downloads the certificate and returns it.
|
||||||
|
// If still pending, returns pending status for continued polling.
|
||||||
|
func (c *Connector) GetOrderStatus(ctx context.Context, orderID string) (*issuer.OrderStatus, error) {
|
||||||
|
c.logger.Debug("checking Sectigo enrollment status", "ssl_id", orderID)
|
||||||
|
|
||||||
|
// Parse sslId from string
|
||||||
|
var sslId int
|
||||||
|
if _, err := fmt.Sscanf(orderID, "%d", &sslId); err != nil {
|
||||||
|
return nil, fmt.Errorf("invalid Sectigo ssl_id: %s", orderID)
|
||||||
|
}
|
||||||
|
|
||||||
|
status, err := c.checkStatus(ctx, sslId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
switch status.Status {
|
||||||
|
case "Issued":
|
||||||
|
certPEM, chainPEM, serial, notBefore, notAfter, collectErr := c.collectCertificate(ctx, sslId)
|
||||||
|
if collectErr != nil {
|
||||||
|
// Cert approved but not yet generated — treat as pending
|
||||||
|
if isCollectNotReady(collectErr) {
|
||||||
|
msg := fmt.Sprintf("enrollment %s is issued but certificate not yet generated", orderID)
|
||||||
|
return &issuer.OrderStatus{
|
||||||
|
OrderID: orderID,
|
||||||
|
Status: "pending",
|
||||||
|
Message: &msg,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("failed to collect certificate: %w", collectErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.logger.Info("Sectigo enrollment completed",
|
||||||
|
"ssl_id", orderID,
|
||||||
|
"serial", serial)
|
||||||
|
|
||||||
|
return &issuer.OrderStatus{
|
||||||
|
OrderID: orderID,
|
||||||
|
Status: "completed",
|
||||||
|
CertPEM: &certPEM,
|
||||||
|
ChainPEM: &chainPEM,
|
||||||
|
Serial: &serial,
|
||||||
|
NotBefore: ¬Before,
|
||||||
|
NotAfter: ¬After,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
case "Applied", "Pending":
|
||||||
|
msg := fmt.Sprintf("enrollment %s is %s", orderID, status.Status)
|
||||||
|
return &issuer.OrderStatus{
|
||||||
|
OrderID: orderID,
|
||||||
|
Status: "pending",
|
||||||
|
Message: &msg,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
case "Rejected":
|
||||||
|
msg := fmt.Sprintf("enrollment %s was rejected", orderID)
|
||||||
|
return &issuer.OrderStatus{
|
||||||
|
OrderID: orderID,
|
||||||
|
Status: "failed",
|
||||||
|
Message: &msg,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
case "Revoked", "Expired", "Not Enrolled":
|
||||||
|
msg := fmt.Sprintf("enrollment %s has status: %s", orderID, status.Status)
|
||||||
|
return &issuer.OrderStatus{
|
||||||
|
OrderID: orderID,
|
||||||
|
Status: "failed",
|
||||||
|
Message: &msg,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
default:
|
||||||
|
msg := fmt.Sprintf("unknown enrollment status: %s", status.Status)
|
||||||
|
return &issuer.OrderStatus{
|
||||||
|
OrderID: orderID,
|
||||||
|
Status: "pending",
|
||||||
|
Message: &msg,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkStatus retrieves the enrollment status from Sectigo.
|
||||||
|
func (c *Connector) checkStatus(ctx context.Context, sslId int) (*statusResponse, error) {
|
||||||
|
statusURL := fmt.Sprintf("%s/ssl/v1/%d", c.config.BaseURL, sslId)
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, statusURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create status request: %w", err)
|
||||||
|
}
|
||||||
|
c.setAuthHeaders(req)
|
||||||
|
|
||||||
|
resp, err := c.httpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Sectigo status request failed: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
respBody, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to read status response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("Sectigo status returned %d: %s", resp.StatusCode, string(respBody))
|
||||||
|
}
|
||||||
|
|
||||||
|
var statusResp statusResponse
|
||||||
|
if err := json.Unmarshal(respBody, &statusResp); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to parse status response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &statusResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// collectCertificate downloads the PEM bundle for a Sectigo certificate.
|
||||||
|
func (c *Connector) collectCertificate(ctx context.Context, sslId int) (certPEM string, chainPEM string, serial string, notBefore time.Time, notAfter time.Time, err error) {
|
||||||
|
collectURL := fmt.Sprintf("%s/ssl/v1/collect/%d/pem", c.config.BaseURL, sslId)
|
||||||
|
req, reqErr := http.NewRequestWithContext(ctx, http.MethodGet, collectURL, nil)
|
||||||
|
if reqErr != nil {
|
||||||
|
err = fmt.Errorf("failed to create collect request: %w", reqErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.setAuthHeaders(req)
|
||||||
|
|
||||||
|
resp, doErr := c.httpClient.Do(req)
|
||||||
|
if doErr != nil {
|
||||||
|
err = fmt.Errorf("Sectigo collect request failed: %w", doErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
body, readErr := io.ReadAll(resp.Body)
|
||||||
|
if readErr != nil {
|
||||||
|
err = fmt.Errorf("failed to read collect response: %w", readErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sectigo returns 400 with code -183 when cert is approved but not yet generated
|
||||||
|
if resp.StatusCode == http.StatusBadRequest {
|
||||||
|
err = &collectNotReadyError{statusCode: resp.StatusCode, body: string(body)}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
err = fmt.Errorf("Sectigo collect returned status %d: %s", resp.StatusCode, string(body))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the PEM bundle: first cert is the leaf, rest are intermediates
|
||||||
|
certPEM, chainPEM, serial, notBefore, notAfter, err = parsePEMBundle(string(body))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// collectNotReadyError indicates the certificate is not yet generated.
|
||||||
|
type collectNotReadyError struct {
|
||||||
|
statusCode int
|
||||||
|
body string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *collectNotReadyError) Error() string {
|
||||||
|
return fmt.Sprintf("certificate not yet available (status %d): %s", e.statusCode, e.body)
|
||||||
|
}
|
||||||
|
|
||||||
|
// isCollectNotReady checks if an error indicates the cert is not yet generated.
|
||||||
|
func isCollectNotReady(err error) bool {
|
||||||
|
_, ok := err.(*collectNotReadyError)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
// parsePEMBundle splits a PEM bundle into leaf cert and chain, extracting metadata.
|
||||||
|
func parsePEMBundle(bundle string) (certPEM string, chainPEM string, serial string, notBefore time.Time, notAfter time.Time, err error) {
|
||||||
|
var certs []string
|
||||||
|
remaining := bundle
|
||||||
|
|
||||||
|
for {
|
||||||
|
var block *pem.Block
|
||||||
|
block, rest := pem.Decode([]byte(remaining))
|
||||||
|
if block == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if block.Type == "CERTIFICATE" {
|
||||||
|
certs = append(certs, string(pem.EncodeToMemory(block)))
|
||||||
|
}
|
||||||
|
remaining = string(rest)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(certs) == 0 {
|
||||||
|
err = fmt.Errorf("no certificates found in PEM bundle")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
certPEM = certs[0]
|
||||||
|
if len(certs) > 1 {
|
||||||
|
chainPEM = strings.Join(certs[1:], "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse leaf cert for metadata
|
||||||
|
block, _ := pem.Decode([]byte(certPEM))
|
||||||
|
if block == nil {
|
||||||
|
err = fmt.Errorf("failed to decode leaf certificate PEM")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cert, parseErr := x509.ParseCertificate(block.Bytes)
|
||||||
|
if parseErr != nil {
|
||||||
|
err = fmt.Errorf("failed to parse leaf certificate: %w", parseErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
serial = cert.SerialNumber.String()
|
||||||
|
notBefore = cert.NotBefore
|
||||||
|
notAfter = cert.NotAfter
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// mapRevocationReason maps RFC 5280 / certctl reason strings to Sectigo reason strings.
|
||||||
|
func mapRevocationReason(reason string) string {
|
||||||
|
switch strings.ToLower(reason) {
|
||||||
|
case "keycompromise", "key_compromise":
|
||||||
|
return "Compromised"
|
||||||
|
case "cessationofoperation", "cessation_of_operation":
|
||||||
|
return "Cessation of Operation"
|
||||||
|
case "affiliationchanged", "affiliation_changed":
|
||||||
|
return "Affiliation Changed"
|
||||||
|
case "superseded":
|
||||||
|
return "Superseded"
|
||||||
|
default:
|
||||||
|
return "Unspecified"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenerateCRL is not supported because Sectigo manages CRL distribution.
|
||||||
|
func (c *Connector) GenerateCRL(ctx context.Context, revokedCerts []issuer.RevokedCertEntry) ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("Sectigo manages CRL distribution; use Sectigo's CRL endpoints")
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignOCSPResponse is not supported because Sectigo manages OCSP.
|
||||||
|
func (c *Connector) SignOCSPResponse(ctx context.Context, req issuer.OCSPSignRequest) ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("Sectigo manages OCSP; use Sectigo's OCSP responder")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCACertPEM is not directly supported. Sectigo intermediate certificates
|
||||||
|
// come with each certificate issuance as part of the PEM bundle.
|
||||||
|
func (c *Connector) GetCACertPEM(ctx context.Context) (string, error) {
|
||||||
|
return "", fmt.Errorf("Sectigo intermediate certificates are included with each issued certificate")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRenewalInfo returns nil, nil as Sectigo does not support ACME Renewal Information (ARI).
|
||||||
|
func (c *Connector) GetRenewalInfo(ctx context.Context, certPEM string) (*issuer.RenewalInfoResult, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure Connector implements the issuer.Connector interface.
|
||||||
|
var _ issuer.Connector = (*Connector)(nil)
|
||||||
@@ -0,0 +1,843 @@
|
|||||||
|
package sectigo_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
|
"crypto/x509"
|
||||||
|
"crypto/x509/pkix"
|
||||||
|
"encoding/json"
|
||||||
|
"encoding/pem"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log/slog"
|
||||||
|
"math/big"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/shankar0123/certctl/internal/connector/issuer"
|
||||||
|
"github.com/shankar0123/certctl/internal/connector/issuer/sectigo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSectigoConnector(t *testing.T) {
|
||||||
|
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
t.Run("ValidateConfig_Success", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path == "/ssl/v1/types" {
|
||||||
|
// Verify all 3 auth headers are present
|
||||||
|
if r.Header.Get("customerUri") != "test-org" {
|
||||||
|
t.Errorf("Expected customerUri 'test-org', got '%s'", r.Header.Get("customerUri"))
|
||||||
|
}
|
||||||
|
if r.Header.Get("login") != "api-user" {
|
||||||
|
t.Errorf("Expected login 'api-user', got '%s'", r.Header.Get("login"))
|
||||||
|
}
|
||||||
|
if r.Header.Get("password") != "api-pass" {
|
||||||
|
t.Errorf("Expected password 'api-pass', got '%s'", r.Header.Get("password"))
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`[{"id":423,"name":"Sectigo OV SSL","term":[365,730]}]`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := sectigo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
Term: 365,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
|
||||||
|
connector := sectigo.New(nil, logger)
|
||||||
|
rawConfig, _ := json.Marshal(config)
|
||||||
|
err := connector.ValidateConfig(ctx, rawConfig)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ValidateConfig failed: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ValidateConfig_MissingCustomerURI", func(t *testing.T) {
|
||||||
|
config := sectigo.Config{
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
}
|
||||||
|
|
||||||
|
connector := sectigo.New(nil, logger)
|
||||||
|
rawConfig, _ := json.Marshal(config)
|
||||||
|
err := connector.ValidateConfig(ctx, rawConfig)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for missing customer_uri")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "customer_uri is required") {
|
||||||
|
t.Errorf("Expected customer_uri required error, got: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ValidateConfig_MissingLogin", func(t *testing.T) {
|
||||||
|
config := sectigo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
}
|
||||||
|
|
||||||
|
connector := sectigo.New(nil, logger)
|
||||||
|
rawConfig, _ := json.Marshal(config)
|
||||||
|
err := connector.ValidateConfig(ctx, rawConfig)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for missing login")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "login is required") {
|
||||||
|
t.Errorf("Expected login required error, got: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ValidateConfig_MissingPassword", func(t *testing.T) {
|
||||||
|
config := sectigo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
OrgID: 12345,
|
||||||
|
}
|
||||||
|
|
||||||
|
connector := sectigo.New(nil, logger)
|
||||||
|
rawConfig, _ := json.Marshal(config)
|
||||||
|
err := connector.ValidateConfig(ctx, rawConfig)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for missing password")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "password is required") {
|
||||||
|
t.Errorf("Expected password required error, got: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ValidateConfig_MissingOrgID", func(t *testing.T) {
|
||||||
|
config := sectigo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
}
|
||||||
|
|
||||||
|
connector := sectigo.New(nil, logger)
|
||||||
|
rawConfig, _ := json.Marshal(config)
|
||||||
|
err := connector.ValidateConfig(ctx, rawConfig)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for missing org_id")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "org_id is required") {
|
||||||
|
t.Errorf("Expected org_id required error, got: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ValidateConfig_InvalidCredentials", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path == "/ssl/v1/types" {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
w.Write([]byte(`{"code":0,"description":"Invalid credentials"}`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := sectigo.Config{
|
||||||
|
CustomerURI: "bad-org",
|
||||||
|
Login: "bad-user",
|
||||||
|
Password: "bad-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
|
||||||
|
connector := sectigo.New(nil, logger)
|
||||||
|
rawConfig, _ := json.Marshal(config)
|
||||||
|
err := connector.ValidateConfig(ctx, rawConfig)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for invalid credentials")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "invalid") {
|
||||||
|
t.Logf("Got error: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("IssueCertificate_ImmediateSuccess", func(t *testing.T) {
|
||||||
|
testCertPEM, _ := generateTestCert(t)
|
||||||
|
testChainPEM, _ := generateTestCert(t)
|
||||||
|
pemBundle := testCertPEM + testChainPEM
|
||||||
|
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// Verify auth headers on every request
|
||||||
|
if r.Header.Get("customerUri") == "" || r.Header.Get("login") == "" || r.Header.Get("password") == "" {
|
||||||
|
t.Error("Missing auth headers on request")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case r.URL.Path == "/ssl/v1/enroll" && r.Method == http.MethodPost:
|
||||||
|
// Verify request body structure
|
||||||
|
body, _ := io.ReadAll(r.Body)
|
||||||
|
var req map[string]interface{}
|
||||||
|
json.Unmarshal(body, &req)
|
||||||
|
if req["orgId"] == nil {
|
||||||
|
t.Error("Expected orgId in enrollment request")
|
||||||
|
}
|
||||||
|
if req["certType"] == nil {
|
||||||
|
t.Error("Expected certType in enrollment request")
|
||||||
|
}
|
||||||
|
// SANs should be comma-separated string, not array
|
||||||
|
if sans, ok := req["subjAltNames"].(string); ok {
|
||||||
|
if !strings.Contains(sans, ",") && len(sans) > 0 {
|
||||||
|
// Single SAN is fine
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55001,"renewId":"ren-abc"}`))
|
||||||
|
|
||||||
|
case r.URL.Path == "/ssl/v1/55001" && r.Method == http.MethodGet:
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55001,"status":"Issued","commonName":"app.example.com"}`))
|
||||||
|
|
||||||
|
case r.URL.Path == "/ssl/v1/collect/55001/pem" && r.Method == http.MethodGet:
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(pemBundle))
|
||||||
|
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
Term: 365,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
_, csrPEM := generateTestCSR(t, "app.example.com")
|
||||||
|
req := issuer.IssuanceRequest{
|
||||||
|
CommonName: "app.example.com",
|
||||||
|
SANs: []string{"app.example.com", "www.example.com"},
|
||||||
|
CSRPEM: csrPEM,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := connector.IssueCertificate(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("IssueCertificate failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.CertPEM == "" {
|
||||||
|
t.Error("CertPEM should not be empty for immediate issuance")
|
||||||
|
}
|
||||||
|
if result.Serial == "" {
|
||||||
|
t.Error("Serial should not be empty for immediate issuance")
|
||||||
|
}
|
||||||
|
if result.OrderID != "55001" {
|
||||||
|
t.Errorf("Expected OrderID '55001', got '%s'", result.OrderID)
|
||||||
|
}
|
||||||
|
t.Logf("Sectigo issued cert: serial=%s, orderID=%s", result.Serial, result.OrderID)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("IssueCertificate_Pending", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/ssl/v1/enroll":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55002}`))
|
||||||
|
case "/ssl/v1/55002":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55002,"status":"Applied","commonName":"secure.example.com"}`))
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
Term: 365,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
_, csrPEM := generateTestCSR(t, "secure.example.com")
|
||||||
|
req := issuer.IssuanceRequest{
|
||||||
|
CommonName: "secure.example.com",
|
||||||
|
CSRPEM: csrPEM,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := connector.IssueCertificate(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("IssueCertificate failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.OrderID != "55002" {
|
||||||
|
t.Errorf("Expected OrderID '55002', got '%s'", result.OrderID)
|
||||||
|
}
|
||||||
|
if result.CertPEM != "" {
|
||||||
|
t.Error("CertPEM should be empty for pending order")
|
||||||
|
}
|
||||||
|
if result.Serial != "" {
|
||||||
|
t.Error("Serial should be empty for pending order")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("IssueCertificate_ServerError", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write([]byte(`{"code":-14,"description":"Invalid CSR"}`))
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
Term: 365,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
req := issuer.IssuanceRequest{
|
||||||
|
CommonName: "test.example.com",
|
||||||
|
CSRPEM: "invalid-csr",
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := connector.IssueCertificate(ctx, req)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for server error response")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetOrderStatus_Issued", func(t *testing.T) {
|
||||||
|
testCertPEM, _ := generateTestCert(t)
|
||||||
|
testChainPEM, _ := generateTestCert(t)
|
||||||
|
pemBundle := testCertPEM + testChainPEM
|
||||||
|
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/ssl/v1/55001":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55001,"status":"Issued","commonName":"app.example.com"}`))
|
||||||
|
case "/ssl/v1/collect/55001/pem":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(pemBundle))
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
status, err := connector.GetOrderStatus(ctx, "55001")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetOrderStatus failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status.Status != "completed" {
|
||||||
|
t.Errorf("Expected status 'completed', got '%s'", status.Status)
|
||||||
|
}
|
||||||
|
if status.CertPEM == nil || *status.CertPEM == "" {
|
||||||
|
t.Error("CertPEM should not be empty for issued order")
|
||||||
|
}
|
||||||
|
if status.Serial == nil || *status.Serial == "" {
|
||||||
|
t.Error("Serial should not be empty for issued order")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetOrderStatus_Pending", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path == "/ssl/v1/55002" {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55002,"status":"Applied"}`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
status, err := connector.GetOrderStatus(ctx, "55002")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetOrderStatus failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status.Status != "pending" {
|
||||||
|
t.Errorf("Expected status 'pending', got '%s'", status.Status)
|
||||||
|
}
|
||||||
|
if status.CertPEM != nil {
|
||||||
|
t.Error("CertPEM should be nil for pending order")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetOrderStatus_Rejected", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path == "/ssl/v1/55003" {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55003,"status":"Rejected"}`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
status, err := connector.GetOrderStatus(ctx, "55003")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetOrderStatus failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status.Status != "failed" {
|
||||||
|
t.Errorf("Expected status 'failed', got '%s'", status.Status)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetOrderStatus_CollectNotReady", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/ssl/v1/55004":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55004,"status":"Issued","commonName":"pending-collect.example.com"}`))
|
||||||
|
case "/ssl/v1/collect/55004/pem":
|
||||||
|
// Sectigo returns 400 with code -183 when cert not yet generated
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write([]byte(`{"code":-183,"description":"Certificate is not available"}`))
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
status, err := connector.GetOrderStatus(ctx, "55004")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetOrderStatus failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should be treated as pending (cert approved but not yet generated)
|
||||||
|
if status.Status != "pending" {
|
||||||
|
t.Errorf("Expected status 'pending' for collect-not-ready, got '%s'", status.Status)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("RenewCertificate_NewOrder", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/ssl/v1/enroll":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55010}`))
|
||||||
|
case "/ssl/v1/55010":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55010,"status":"Applied"}`))
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
Term: 365,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
_, csrPEM := generateTestCSR(t, "renew.example.com")
|
||||||
|
renewReq := issuer.RenewalRequest{
|
||||||
|
CommonName: "renew.example.com",
|
||||||
|
CSRPEM: csrPEM,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := connector.RenewCertificate(ctx, renewReq)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("RenewCertificate failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.OrderID == "" {
|
||||||
|
t.Error("OrderID should not be empty")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("RevokeCertificate_Success", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if strings.HasPrefix(r.URL.Path, "/ssl/v1/revoke/") && r.Method == http.MethodPost {
|
||||||
|
// Verify auth headers
|
||||||
|
if r.Header.Get("customerUri") == "" {
|
||||||
|
t.Error("Missing customerUri header on revoke request")
|
||||||
|
}
|
||||||
|
if r.Header.Get("login") == "" {
|
||||||
|
t.Error("Missing login header on revoke request")
|
||||||
|
}
|
||||||
|
if r.Header.Get("password") == "" {
|
||||||
|
t.Error("Missing password header on revoke request")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify reason in body
|
||||||
|
body, _ := io.ReadAll(r.Body)
|
||||||
|
var req map[string]interface{}
|
||||||
|
json.Unmarshal(body, &req)
|
||||||
|
if req["reason"] == nil {
|
||||||
|
t.Error("Expected reason in revoke request body")
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
reason := "keyCompromise"
|
||||||
|
revokeReq := issuer.RevocationRequest{
|
||||||
|
Serial: "55001",
|
||||||
|
Reason: &reason,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := connector.RevokeCertificate(ctx, revokeReq)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("RevokeCertificate failed: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("RevokeCertificate_Error", func(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write([]byte(`{"code":-1,"description":"Certificate not found"}`))
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
revokeReq := issuer.RevocationRequest{
|
||||||
|
Serial: "00000",
|
||||||
|
}
|
||||||
|
|
||||||
|
err := connector.RevokeCertificate(ctx, revokeReq)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error for revocation of nonexistent cert")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetRenewalInfo_ReturnsNil", func(t *testing.T) {
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: "https://cert-manager.com/api",
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
result, err := connector.GetRenewalInfo(ctx, "-----BEGIN CERTIFICATE-----\ntest\n-----END CERTIFICATE-----")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetRenewalInfo should not return error, got: %v", err)
|
||||||
|
}
|
||||||
|
if result != nil {
|
||||||
|
t.Fatal("GetRenewalInfo should return nil for Sectigo")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("DefaultTerm", func(t *testing.T) {
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
// Term intentionally left as 0
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
// Verify the connector was created (the default is set in New())
|
||||||
|
if connector == nil {
|
||||||
|
t.Fatal("Connector should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify via a request that uses the term
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path == "/ssl/v1/enroll" {
|
||||||
|
body, _ := io.ReadAll(r.Body)
|
||||||
|
var req map[string]interface{}
|
||||||
|
json.Unmarshal(body, &req)
|
||||||
|
// Default term should be 365
|
||||||
|
if term, ok := req["term"].(float64); ok {
|
||||||
|
if int(term) != 365 {
|
||||||
|
t.Errorf("Expected default term 365, got %d", int(term))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55099}`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r.URL.Path == "/ssl/v1/55099" {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55099,"status":"Applied"}`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
// Reconfigure with test server URL
|
||||||
|
config.BaseURL = srv.URL
|
||||||
|
connector = sectigo.New(config, logger)
|
||||||
|
|
||||||
|
_, csrPEM := generateTestCSR(t, "test.example.com")
|
||||||
|
req := issuer.IssuanceRequest{
|
||||||
|
CommonName: "test.example.com",
|
||||||
|
CSRPEM: csrPEM,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := connector.IssueCertificate(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("IssueCertificate with default term failed: %v", err)
|
||||||
|
}
|
||||||
|
if result.OrderID == "" {
|
||||||
|
t.Error("OrderID should not be empty")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("AuthHeaders_PresentOnAllRequests", func(t *testing.T) {
|
||||||
|
requestCount := 0
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
requestCount++
|
||||||
|
// Every single request must have all 3 auth headers
|
||||||
|
if r.Header.Get("customerUri") != "verify-org" {
|
||||||
|
t.Errorf("Request %d: expected customerUri 'verify-org', got '%s'", requestCount, r.Header.Get("customerUri"))
|
||||||
|
}
|
||||||
|
if r.Header.Get("login") != "verify-user" {
|
||||||
|
t.Errorf("Request %d: expected login 'verify-user', got '%s'", requestCount, r.Header.Get("login"))
|
||||||
|
}
|
||||||
|
if r.Header.Get("password") != "verify-pass" {
|
||||||
|
t.Errorf("Request %d: expected password 'verify-pass', got '%s'", requestCount, r.Header.Get("password"))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/ssl/v1/enroll":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55050}`))
|
||||||
|
case "/ssl/v1/55050":
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte(`{"sslId":55050,"status":"Applied"}`))
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "verify-org",
|
||||||
|
Login: "verify-user",
|
||||||
|
Password: "verify-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
CertType: 423,
|
||||||
|
Term: 365,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
_, csrPEM := generateTestCSR(t, "auth-check.example.com")
|
||||||
|
req := issuer.IssuanceRequest{
|
||||||
|
CommonName: "auth-check.example.com",
|
||||||
|
CSRPEM: csrPEM,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := connector.IssueCertificate(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("IssueCertificate failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if requestCount < 2 {
|
||||||
|
t.Errorf("Expected at least 2 requests (enroll + status), got %d", requestCount)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("RevocationReasonMapping", func(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"keyCompromise", "Compromised"},
|
||||||
|
{"cessationOfOperation", "Cessation of Operation"},
|
||||||
|
{"affiliationChanged", "Affiliation Changed"},
|
||||||
|
{"superseded", "Superseded"},
|
||||||
|
{"unspecified", "Unspecified"},
|
||||||
|
{"unknown_reason", "Unspecified"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.input, func(t *testing.T) {
|
||||||
|
var receivedReason string
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if strings.HasPrefix(r.URL.Path, "/ssl/v1/revoke/") {
|
||||||
|
body, _ := io.ReadAll(r.Body)
|
||||||
|
var req map[string]interface{}
|
||||||
|
json.Unmarshal(body, &req)
|
||||||
|
receivedReason = req["reason"].(string)
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
config := §igo.Config{
|
||||||
|
CustomerURI: "test-org",
|
||||||
|
Login: "api-user",
|
||||||
|
Password: "api-pass",
|
||||||
|
OrgID: 12345,
|
||||||
|
BaseURL: srv.URL,
|
||||||
|
}
|
||||||
|
connector := sectigo.New(config, logger)
|
||||||
|
|
||||||
|
reason := tt.input
|
||||||
|
err := connector.RevokeCertificate(ctx, issuer.RevocationRequest{
|
||||||
|
Serial: "12345",
|
||||||
|
Reason: &reason,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("RevokeCertificate failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if receivedReason != tt.expected {
|
||||||
|
t.Errorf("Expected reason '%s', got '%s'", tt.expected, receivedReason)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// generateTestCert creates a self-signed test certificate and returns the PEM strings.
|
||||||
|
func generateTestCert(t *testing.T) (certPEM string, keyPEM string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
key, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to generate key: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
serial, _ := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128))
|
||||||
|
template := &x509.Certificate{
|
||||||
|
SerialNumber: serial,
|
||||||
|
Subject: pkix.Name{
|
||||||
|
CommonName: fmt.Sprintf("Test Certificate %s", serial.String()[:8]),
|
||||||
|
},
|
||||||
|
DNSNames: []string{"test.example.com"},
|
||||||
|
KeyUsage: x509.KeyUsageDigitalSignature,
|
||||||
|
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
||||||
|
BasicConstraintsValid: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
certBytes, err := x509.CreateCertificate(rand.Reader, template, template, &key.PublicKey, key)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create certificate: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
certPEM = string(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certBytes}))
|
||||||
|
keyPEM = string(pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}))
|
||||||
|
|
||||||
|
return certPEM, keyPEM
|
||||||
|
}
|
||||||
|
|
||||||
|
// generateTestCSR creates a test CSR for the given common name.
|
||||||
|
func generateTestCSR(t *testing.T, commonName string) (*x509.CertificateRequest, string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
key, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to generate key: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
csrTemplate := x509.CertificateRequest{
|
||||||
|
Subject: pkix.Name{
|
||||||
|
CommonName: commonName,
|
||||||
|
},
|
||||||
|
DNSNames: []string{commonName},
|
||||||
|
SignatureAlgorithm: x509.SHA256WithRSA,
|
||||||
|
}
|
||||||
|
|
||||||
|
csrBytes, err := x509.CreateCertificateRequest(rand.Reader, &csrTemplate, key)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create CSR: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
csrPEM := string(pem.EncodeToMemory(&pem.Block{
|
||||||
|
Type: "CERTIFICATE REQUEST",
|
||||||
|
Bytes: csrBytes,
|
||||||
|
}))
|
||||||
|
|
||||||
|
csr, err := x509.ParseCertificateRequest(csrBytes)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to parse CSR: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return csr, csrPEM
|
||||||
|
}
|
||||||
@@ -71,6 +71,7 @@ const (
|
|||||||
IssuerTypeOpenSSL IssuerType = "OpenSSL"
|
IssuerTypeOpenSSL IssuerType = "OpenSSL"
|
||||||
IssuerTypeVault IssuerType = "VaultPKI"
|
IssuerTypeVault IssuerType = "VaultPKI"
|
||||||
IssuerTypeDigiCert IssuerType = "DigiCert"
|
IssuerTypeDigiCert IssuerType = "DigiCert"
|
||||||
|
IssuerTypeSectigo IssuerType = "Sectigo"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TargetType represents the type of deployment target.
|
// TargetType represents the type of deployment target.
|
||||||
|
|||||||
+25
-24
@@ -39,46 +39,47 @@ ON CONFLICT (id) DO NOTHING;
|
|||||||
-- 3. Issuers
|
-- 3. Issuers
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
INSERT INTO issuers (id, name, type, config, enabled, created_at, updated_at) VALUES
|
INSERT INTO issuers (id, name, type, config, enabled, created_at, updated_at) VALUES
|
||||||
('iss-local', 'Local Dev CA', 'local', '{"ca_common_name": "CertCtl Demo CA", "validity_days": 90}', true, NOW() - INTERVAL '180 days', NOW() - INTERVAL '180 days'),
|
('iss-local', 'Local Dev CA', 'GenericCA', '{"ca_common_name": "CertCtl Demo CA", "validity_days": 90}', true, NOW() - INTERVAL '180 days', NOW() - INTERVAL '180 days'),
|
||||||
('iss-acme-le', 'Let''s Encrypt Staging', 'acme', '{"directory_url": "https://acme-staging-v02.api.letsencrypt.org/directory", "email": "admin@example.com", "challenge_type": "http-01"}', true, NOW() - INTERVAL '150 days', NOW() - INTERVAL '150 days'),
|
('iss-acme-le', 'Let''s Encrypt Staging', 'ACME', '{"directory_url": "https://acme-staging-v02.api.letsencrypt.org/directory", "email": "admin@example.com", "challenge_type": "http-01"}', true, NOW() - INTERVAL '150 days', NOW() - INTERVAL '150 days'),
|
||||||
('iss-stepca', 'step-ca Internal', 'stepca', '{"ca_url": "https://ca.internal:9000", "provisioner_name": "certctl", "validity_days": 90}', true, NOW() - INTERVAL '120 days', NOW() - INTERVAL '120 days'),
|
('iss-stepca', 'step-ca Internal', 'StepCA', '{"ca_url": "https://ca.internal:9000", "provisioner_name": "certctl", "validity_days": 90}', true, NOW() - INTERVAL '120 days', NOW() - INTERVAL '120 days'),
|
||||||
('iss-acme-zs', 'ZeroSSL (EAB)', 'acme', '{"directory_url": "https://acme.zerossl.com/v2/DV90", "email": "admin@example.com", "challenge_type": "http-01"}', true, NOW() - INTERVAL '60 days', NOW() - INTERVAL '60 days'),
|
('iss-acme-zs', 'ZeroSSL (EAB)', 'ACME', '{"directory_url": "https://acme.zerossl.com/v2/DV90", "email": "admin@example.com", "challenge_type": "http-01"}', true, NOW() - INTERVAL '60 days', NOW() - INTERVAL '60 days'),
|
||||||
('iss-openssl', 'Custom OpenSSL CA', 'openssl', '{"sign_script": "/opt/ca/sign.sh", "timeout_seconds": 30}', false, NOW() - INTERVAL '30 days', NOW() - INTERVAL '30 days'),
|
('iss-openssl', 'Custom OpenSSL CA', 'OpenSSL', '{"sign_script": "/opt/ca/sign.sh", "timeout_seconds": 30}', false, NOW() - INTERVAL '30 days', NOW() - INTERVAL '30 days'),
|
||||||
('iss-vault', 'HashiCorp Vault PKI', 'VaultPKI', '{"addr": "https://vault.internal:8200", "mount": "pki", "role": "web-certs", "ttl": "8760h"}', true, NOW() - INTERVAL '20 days', NOW() - INTERVAL '20 days'),
|
('iss-vault', 'HashiCorp Vault PKI', 'VaultPKI', '{"addr": "https://vault.internal:8200", "mount": "pki", "role": "web-certs", "ttl": "8760h"}', true, NOW() - INTERVAL '20 days', NOW() - INTERVAL '20 days'),
|
||||||
('iss-digicert', 'DigiCert CertCentral', 'DigiCert', '{"base_url": "https://www.digicert.com/services/v2", "product_type": "ssl_basic"}', true, NOW() - INTERVAL '15 days', NOW() - INTERVAL '15 days')
|
('iss-digicert', 'DigiCert CertCentral', 'DigiCert', '{"base_url": "https://www.digicert.com/services/v2", "product_type": "ssl_basic"}', true, NOW() - INTERVAL '15 days', NOW() - INTERVAL '15 days'),
|
||||||
|
('iss-sectigo', 'Sectigo SCM', 'Sectigo', '{"base_url": "https://cert-manager.com/api", "cert_type": 423, "term": 365}', true, NOW() - INTERVAL '10 days', NOW() - INTERVAL '10 days')
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- 4. Agents (8 agents across multiple platforms)
|
-- 4. Agents (8 agents across multiple platforms)
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at, api_key_hash, os, architecture, ip_address, version) VALUES
|
INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at, api_key_hash, os, architecture, ip_address, version) VALUES
|
||||||
('ag-web-prod', 'web-prod-agent', 'web-prod-01.internal', 'online', NOW() - INTERVAL '30 seconds', NOW() - INTERVAL '120 days', 'demo_hash_1', 'linux', 'amd64', '10.0.1.10', '2.0.14'),
|
('ag-web-prod', 'web-prod-agent', 'web-prod-01.internal', 'Online', NOW() - INTERVAL '30 seconds', NOW() - INTERVAL '120 days', 'demo_hash_1', 'linux', 'amd64', '10.0.1.10', '2.0.14'),
|
||||||
('ag-web-staging', 'web-staging-agent', 'web-stg-01.internal', 'online', NOW() - INTERVAL '45 seconds', NOW() - INTERVAL '90 days', 'demo_hash_2', 'linux', 'amd64', '10.0.2.20', '2.0.14'),
|
('ag-web-staging', 'web-staging-agent', 'web-stg-01.internal', 'Online', NOW() - INTERVAL '45 seconds', NOW() - INTERVAL '90 days', 'demo_hash_2', 'linux', 'amd64', '10.0.2.20', '2.0.14'),
|
||||||
('ag-lb-prod', 'lb-prod-agent', 'lb-prod-01.internal', 'online', NOW() - INTERVAL '15 seconds', NOW() - INTERVAL '150 days', 'demo_hash_3', 'linux', 'amd64', '10.0.1.50', '2.0.14'),
|
('ag-lb-prod', 'lb-prod-agent', 'lb-prod-01.internal', 'Online', NOW() - INTERVAL '15 seconds', NOW() - INTERVAL '150 days', 'demo_hash_3', 'linux', 'amd64', '10.0.1.50', '2.0.14'),
|
||||||
('ag-iis-prod', 'iis-prod-agent', 'iis-prod-01.internal', 'offline', NOW() - INTERVAL '3 hours', NOW() - INTERVAL '60 days', 'demo_hash_4', 'windows', 'amd64', '10.0.3.15', '2.0.12'),
|
('ag-iis-prod', 'iis-prod-agent', 'iis-prod-01.internal', 'Offline', NOW() - INTERVAL '3 hours', NOW() - INTERVAL '60 days', 'demo_hash_4', 'windows', 'amd64', '10.0.3.15', '2.0.12'),
|
||||||
('ag-data-prod', 'data-prod-agent', 'data-prod-01.internal', 'online', NOW() - INTERVAL '20 seconds', NOW() - INTERVAL '90 days', 'demo_hash_5', 'linux', 'arm64', '10.0.4.30', '2.0.14'),
|
('ag-data-prod', 'data-prod-agent', 'data-prod-01.internal', 'Online', NOW() - INTERVAL '20 seconds', NOW() - INTERVAL '90 days', 'demo_hash_5', 'linux', 'arm64', '10.0.4.30', '2.0.14'),
|
||||||
('ag-edge-01', 'edge-eu-agent', 'edge-eu-01.internal', 'online', NOW() - INTERVAL '50 seconds', NOW() - INTERVAL '45 days', 'demo_hash_6', 'linux', 'arm64', '10.0.5.10', '2.0.14'),
|
('ag-edge-01', 'edge-eu-agent', 'edge-eu-01.internal', 'Online', NOW() - INTERVAL '50 seconds', NOW() - INTERVAL '45 days', 'demo_hash_6', 'linux', 'arm64', '10.0.5.10', '2.0.14'),
|
||||||
('ag-k8s-prod', 'k8s-prod-agent', 'k8s-node-01.internal', 'online', NOW() - INTERVAL '10 seconds', NOW() - INTERVAL '30 days', 'demo_hash_7', 'linux', 'amd64', '10.0.6.10', '2.0.14'),
|
('ag-k8s-prod', 'k8s-prod-agent', 'k8s-node-01.internal', 'Online', NOW() - INTERVAL '10 seconds', NOW() - INTERVAL '30 days', 'demo_hash_7', 'linux', 'amd64', '10.0.6.10', '2.0.14'),
|
||||||
('ag-mac-dev', 'mac-dev-agent', 'dev-mac-01.internal', 'online', NOW() - INTERVAL '60 seconds', NOW() - INTERVAL '15 days', 'demo_hash_8', 'darwin', 'arm64', '10.0.7.5', '2.0.14')
|
('ag-mac-dev', 'mac-dev-agent', 'dev-mac-01.internal', 'Online', NOW() - INTERVAL '60 seconds', NOW() - INTERVAL '15 days', 'demo_hash_8', 'darwin', 'arm64', '10.0.7.5', '2.0.14')
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
-- Sentinel agent for network-discovered certificates
|
-- Sentinel agent for network-discovered certificates
|
||||||
INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at, api_key_hash, os, architecture, ip_address, version) VALUES
|
INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at, api_key_hash, os, architecture, ip_address, version) VALUES
|
||||||
('server-scanner', 'Network Scanner (Server-Side)', 'certctl-server', 'online', NOW(), NOW() - INTERVAL '90 days', 'sentinel_no_auth', 'linux', 'amd64', '127.0.0.1', '2.0.14')
|
('server-scanner', 'Network Scanner (Server-Side)', 'certctl-server', 'Online', NOW(), NOW() - INTERVAL '90 days', 'sentinel_no_auth', 'linux', 'amd64', '127.0.0.1', '2.0.14')
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- 5. Deployment Targets (8 targets across multiple connector types)
|
-- 5. Deployment Targets (8 targets across multiple connector types)
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
INSERT INTO deployment_targets (id, name, type, agent_id, config, enabled, created_at, updated_at) VALUES
|
INSERT INTO deployment_targets (id, name, type, agent_id, config, enabled, created_at, updated_at) VALUES
|
||||||
('tgt-nginx-prod', 'NGINX Production', 'nginx', 'ag-web-prod', '{"cert_path": "/etc/nginx/ssl/cert.pem", "key_path": "/etc/nginx/ssl/key.pem", "reload_command": "nginx -s reload"}', true, NOW() - INTERVAL '120 days', NOW()),
|
('tgt-nginx-prod', 'NGINX Production', 'NGINX', 'ag-web-prod', '{"cert_path": "/etc/nginx/ssl/cert.pem", "key_path": "/etc/nginx/ssl/key.pem", "reload_command": "nginx -s reload"}', true, NOW() - INTERVAL '120 days', NOW()),
|
||||||
('tgt-nginx-staging', 'NGINX Staging', 'nginx', 'ag-web-staging', '{"cert_path": "/etc/nginx/ssl/cert.pem", "key_path": "/etc/nginx/ssl/key.pem", "reload_command": "nginx -s reload"}', true, NOW() - INTERVAL '90 days', NOW()),
|
('tgt-nginx-staging', 'NGINX Staging', 'NGINX', 'ag-web-staging', '{"cert_path": "/etc/nginx/ssl/cert.pem", "key_path": "/etc/nginx/ssl/key.pem", "reload_command": "nginx -s reload"}', true, NOW() - INTERVAL '90 days', NOW()),
|
||||||
('tgt-haproxy-prod', 'HAProxy Production', 'haproxy', 'ag-lb-prod', '{"combined_pem_path": "/etc/haproxy/ssl/site.pem", "reload_command": "systemctl reload haproxy"}', true, NOW() - INTERVAL '150 days', NOW()),
|
('tgt-haproxy-prod', 'HAProxy Production', 'HAProxy', 'ag-lb-prod', '{"combined_pem_path": "/etc/haproxy/ssl/site.pem", "reload_command": "systemctl reload haproxy"}', true, NOW() - INTERVAL '150 days', NOW()),
|
||||||
('tgt-apache-prod', 'Apache Production', 'apache', 'ag-web-prod', '{"cert_path": "/etc/httpd/ssl/cert.pem", "key_path": "/etc/httpd/ssl/key.pem", "chain_path": "/etc/httpd/ssl/chain.pem", "reload_command": "apachectl graceful"}', true, NOW() - INTERVAL '100 days', NOW()),
|
('tgt-apache-prod', 'Apache Production', 'Apache', 'ag-web-prod', '{"cert_path": "/etc/httpd/ssl/cert.pem", "key_path": "/etc/httpd/ssl/key.pem", "chain_path": "/etc/httpd/ssl/chain.pem", "reload_command": "apachectl graceful"}', true, NOW() - INTERVAL '100 days', NOW()),
|
||||||
('tgt-iis-prod', 'IIS Production', 'iis', 'ag-iis-prod', '{"site_name": "Default Web Site", "binding_info": "*:443:"}', true, NOW() - INTERVAL '60 days', NOW()),
|
('tgt-iis-prod', 'IIS Production', 'IIS', 'ag-iis-prod', '{"site_name": "Default Web Site", "binding_info": "*:443:"}', true, NOW() - INTERVAL '60 days', NOW()),
|
||||||
('tgt-traefik-prod', 'Traefik Production', 'traefik', 'ag-k8s-prod', '{"watch_dir": "/etc/traefik/dynamic/certs"}', true, NOW() - INTERVAL '30 days', NOW()),
|
('tgt-traefik-prod', 'Traefik Production', 'Traefik', 'ag-k8s-prod', '{"watch_dir": "/etc/traefik/dynamic/certs"}', true, NOW() - INTERVAL '30 days', NOW()),
|
||||||
('tgt-caddy-prod', 'Caddy Production', 'caddy', 'ag-edge-01', '{"mode": "api", "admin_url": "http://localhost:2019"}', true, NOW() - INTERVAL '45 days', NOW()),
|
('tgt-caddy-prod', 'Caddy Production', 'Caddy', 'ag-edge-01', '{"mode": "api", "admin_url": "http://localhost:2019"}', true, NOW() - INTERVAL '45 days', NOW()),
|
||||||
('tgt-nginx-data', 'NGINX Data Services', 'nginx', 'ag-data-prod', '{"cert_path": "/etc/nginx/ssl/cert.pem", "key_path": "/etc/nginx/ssl/key.pem", "reload_command": "nginx -s reload"}', true, NOW() - INTERVAL '90 days', NOW())
|
('tgt-nginx-data', 'NGINX Data Services', 'NGINX', 'ag-data-prod', '{"cert_path": "/etc/nginx/ssl/cert.pem", "key_path": "/etc/nginx/ssl/key.pem", "reload_command": "nginx -s reload"}', true, NOW() - INTERVAL '90 days', NOW())
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
@@ -128,7 +129,7 @@ INSERT INTO certificate_profiles (id, name, description, allowed_key_algorithms,
|
|||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- 7. Managed Certificates (35 certs across multiple issuers and environments)
|
-- 7. Managed Certificates (32 certs across multiple issuers and environments)
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
INSERT INTO managed_certificates (id, name, common_name, sans, environment, owner_id, team_id, issuer_id, renewal_policy_id, status, expires_at, tags, last_renewal_at, last_deployment_at, created_at, updated_at) VALUES
|
INSERT INTO managed_certificates (id, name, common_name, sans, environment, owner_id, team_id, issuer_id, renewal_policy_id, status, expires_at, tags, last_renewal_at, last_deployment_at, created_at, updated_at) VALUES
|
||||||
-- ---- Active, healthy production certs (Local CA) ----
|
-- ---- Active, healthy production certs (Local CA) ----
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const typeLabels: Record<string, string> = {
|
|||||||
openssl: 'OpenSSL/Custom',
|
openssl: 'OpenSSL/Custom',
|
||||||
VaultPKI: 'Vault PKI',
|
VaultPKI: 'Vault PKI',
|
||||||
DigiCert: 'DigiCert',
|
DigiCert: 'DigiCert',
|
||||||
|
Sectigo: 'Sectigo SCM',
|
||||||
manual: 'Manual',
|
manual: 'Manual',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,12 +121,19 @@ export const issuerTypes: IssuerTypeConfig[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'sectigo',
|
id: 'Sectigo',
|
||||||
name: 'Sectigo',
|
name: 'Sectigo SCM',
|
||||||
description: 'Sectigo Certificate Manager \u2014 coming soon',
|
description: 'Sectigo Certificate Manager for DV, OV, and EV certificates',
|
||||||
icon: '\uD83D\uDCE6',
|
icon: '\uD83D\uDD10',
|
||||||
configFields: [],
|
configFields: [
|
||||||
comingSoon: true,
|
{ key: 'customer_uri', label: 'Customer URI', required: true, placeholder: 'your-org-uri' },
|
||||||
|
{ key: 'login', label: 'API Login', required: true, placeholder: 'api-account-name' },
|
||||||
|
{ key: 'password', label: 'API Password', required: true, sensitive: true, type: 'password' },
|
||||||
|
{ key: 'org_id', label: 'Organization ID', required: true, placeholder: '12345', type: 'number' },
|
||||||
|
{ key: 'cert_type', label: 'Certificate Type ID', required: false, placeholder: '423', type: 'number' },
|
||||||
|
{ key: 'term', label: 'Validity (days)', required: false, placeholder: '365', type: 'number' },
|
||||||
|
{ key: 'base_url', label: 'Base URL', required: false, placeholder: 'https://cert-manager.com/api' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'entrust',
|
id: 'entrust',
|
||||||
|
|||||||
Reference in New Issue
Block a user