Skip to content

Commit cc6aa8e

Browse files
author
James Belchamber
authored
Merge pull request #1 from rpcpool/triton-rewrite
Support for ZeroSSL and NS1
2 parents d246e4e + 1ec4c29 commit cc6aa8e

File tree

21 files changed

+4180
-776
lines changed

21 files changed

+4180
-776
lines changed

.devcontainer/devcontainer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "Certificator",
3+
"image": "docker.io/golang:latest",
4+
"features": {
5+
"ghcr.io/devcontainers/features/common-utils": {
6+
"installZsh": true,
7+
"installOhMyZsh": true,
8+
"installOhMyZshConfig": true,
9+
"configureZshAsDefaultShell": true,
10+
"upgradePackages": true
11+
},
12+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
13+
}
14+
}

.env.dev

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build_and_publish:
14+
name: Build and Publish
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
29+
with:
30+
go-version: "1.24.4"
31+
check-latest: false
32+
33+
- name: Build Executable
34+
run: |
35+
CGO_ENABLED=0 go build -o certificator ./cmd/certificator
36+
37+
- name: Login to GitHub Container Registry
38+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Extract metadata (tags, labels) for Docker
45+
id: meta
46+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
47+
with:
48+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
49+
50+
- name: Build and push Docker image
51+
id: push
52+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
53+
with:
54+
context: .
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
59+
- name: Generate artifact attestation
60+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
61+
with:
62+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
63+
subject-digest: ${{ steps.push.outputs.digest }}
64+
push-to-registry: true

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

Dockerfile

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
1-
# ===========
2-
# Build stage
3-
# ===========
4-
FROM golang:1.16.3-alpine3.13 AS builder
5-
6-
WORKDIR /code
7-
8-
# Pre-install dependencies to cache them as a separate image layer
9-
COPY go.mod go.sum ./
10-
RUN go mod download
11-
12-
# Build
13-
COPY . /code
14-
RUN go build -o certificator ./cmd/certificator
15-
16-
# ===========
17-
# Final stage
18-
# ===========
19-
FROM alpine:3.13.0
1+
FROM alpine:latest
202

213
WORKDIR /app
22-
RUN apk --no-cache add curl
23-
24-
COPY ./fixtures /app/fixtures
25-
COPY ./domains.yml /app/fixtures/domains.yml
264

27-
COPY --from=builder /code/certificator .
5+
COPY certificator /app/certificator
286

29-
CMD [ "./certificator" ]
7+
CMD [ "/app/certificator" ]

Dockerfile.tester

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,7 @@
1-
# certificator
1+
# Triton Certificator
22

3-
The tool that requests certificates from ACME supporting CA, solves DNS challenges, and stores certificates in Vault.
3+
This is a fork of [vinted's certificator](https://github.com/vinted/certificator) tool with customisations made to support our specific use-case, which has removed upstream features, which we have not (yet) attempted to upstream.
44

5-
## Usage
5+
As such this repository has been stripped down, removing various upstream tests which are no longer valid. These can be reintroduced if they are fixed, but there's no value to keeping them while they are not.
66

7-
1. Add domains that need certificates to domains.yml file
8-
1. Set necessary environment variables (see [configuration](#Configuration))
9-
1. Run certificator
10-
1. Find certificates in Vault
11-
12-
## Configuration
13-
14-
Certificator reads most configuration parameters from environment variables.
15-
They are defined in [pkg/config/config.go](pkg/config/config.go) Config struct
16-
17-
Configuration variables:
18-
- `ACME_ACCOUNT_EMAIL` - email used in certificate retrieval process. **Required**
19-
- `ACME_DNS_CHALLENGE_PROVIDER` - DNS challenge provider. Available providers can be found [here](https://go-acme.github.io/lego/dns/#dns-providers). **Required**
20-
- `ACME_DNS_PROPAGATION_REQUIREMENT` - if set to true, requires complete DNS record propagation before stating that challenge is solved. Default: true
21-
- `ACME_REREGISTER_ACCOUNT` - if set to true, allows registering an account with CA. This should be set to true for the first use. When credentials are stored in Vault, you can set this to false to avoid accidental registrations. Default: false
22-
- `ACME_SERVER_URL` - ACME directory location. Default: https://acme-staging-v02.api.letsencrypt.org/directory
23-
- `VAULT_APPROLE_ROLE_ID` - role ID for Vault approle authentication method. **Required in prod env**
24-
- `VAULT_APPROLE_SECRET_ID` - secret ID for Vault approle authentication method. **Required in prod env**
25-
- `VAULT_KV_STORAGE_PATH` - path in Vault KV storage where certificator stores certificates and account data. Default: secret/data/certificator/
26-
- `VAULT_ADDR` sets vault address, example: "http://localhost:8200". **Required**
27-
- `LOG_FORMAT` - logging format, supported formats - JSON and LOGFMT. Default: JSON
28-
- `LOG_LEVEL` - logging level, supported levels - DEBUG, INFO, WARN, ERROR, FATAL. Default: INFO.
29-
- `DNS_ADDRESS` - DNS server address that is used to check challenge DNS record propagation. Default: 127.0.0.1:53
30-
- `ENVIRONMENT` - sets an environment where the certificator is running. If the environment is dev it uses token set in `VAULT_DEV_ROOT_TOKEN_ID` env variable to authenticate in Vault. If the environment is prod it uses an approle authentication method. Default: prod
31-
- `CERTIFICATOR_DOMAINS_FILE` - path to a file where domains are defined. Default: /code/domains.yml
32-
- `CERTIFICATOR_RENEW_BEFORE_DAYS` - set how many validity days should certificate have remaining before renewal. Default: 30
33-
34-
#### CNAME
35-
36-
- `LEGO_EXPERIMENTAL_CNAME_SUPPORT` boolean value which enables CNAME support. When `true`, it tries to resolve `_acme-challenge.<YOUR_DOMAIN>` and if it finds a CNAME record for that request it solves the challenge for the CNAME record value. Example:
37-
38-
```
39-
If it finds this record:
40-
CNAME _acme_challenge.test.com -> test.com.challenges.test.com
41-
it creates TXT record in challenges.test.com zone:
42-
TXT test.com.challenges.test.com -> <CHALLENGE_VALUE>
43-
CA will verify domain ownership following the same scheme
44-
```
45-
46-
This allows giving this tool a token with access rights limited to a single DNS zone.
47-
48-
#### Domains file
49-
50-
Domains that the certificator should retrieve certificates for should be defined in this file in YAML format. An example file is in [domains.yml](domains.yml).
51-
52-
Every item in the array under the `domains` key results in a certificate. The first domain in an array item is used for the CommonName field of the certificate, all other domains are added using the Subject Alternate Names extension. Domains in a single array item are separated by commas. The first domain is also used as a key in the Vault KV store.
53-
54-
## Tests
55-
56-
This project contains unit and integration tests. To run them follow the instructions
57-
58-
#### Integration tests
59-
60-
Files related to integration tests lie in directory `test`.
61-
It relies on several components: pebble, vault, challtestsrv.
62-
63-
Steps to run it:
64-
65-
1. Build container that runs tests:
66-
`docker-compose build tester`
67-
1. Run tests:
68-
- only integration tests:
69-
`docker-compose run --rm tester go test ./test/...`
70-
- all tests:
71-
`docker-compose run --rm tester go test ./...`
72-
1. Check results
73-
1. Bring down testing infrastructure
74-
`docker-compose down`
75-
76-
#### Unit tests
77-
78-
Unit tests can be run without any dependencies, simply execute:
79-
`go test ./pkg/...`
7+
We have also added a devcontainer and a workflow for building the application container ready for use in nomad.

cmd/certificator/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func main() {
4646
logger.Fatal(err)
4747
}
4848

49-
acmeClient, err := acme.NewClient(cfg.Acme.AccountEmail, cfg.Acme.ServerURL,
49+
acmeClient, err := acme.NewClient(cfg.Acme.AccountEmail, cfg.Acme.ServerURL, cfg.Acme.EABKid, cfg.Acme.EABHmacKey,
5050
cfg.Acme.ReregisterAccount, vaultClient, logger)
5151
if err != nil {
5252
logger.Fatal(err)

docker-compose.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

domains.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)