<!-- Generated by website/scripts/sync-docs.mjs from CONTRIBUTING.md. Edit that file, not this one. -->

# Contributing

> Every page of this site: https://dyokto.github.io/y509/docs/llms.txt

Bug reports and patches are welcome. For a suspected vulnerability, use the [security policy](https://dyokto.github.io/y509/docs/security/), not a public issue.

## Getting set up

Go 1.27+ is the only prerequisite. `golangci-lint` and `govulncheck` are pinned as `tool` directives in `go.mod`, so there is nothing separate to install.

```bash
git clone https://github.com/dyokto/y509
cd y509
make run    # builds and opens the demo chain
```

## Before you open a pull request

```bash
make lint       # must report 0 issues
make test       # must pass
make vulncheck  # must be clean
```

CI runs the same three. `make test-coverage` gates at 80%; a patch that drops below it will fail.

## What gets merged

- One commit per logical change. A refactor and a behaviour change belong in separate commits.
- Commit messages in English, conventional-commits style. The subject says what changed, the body says why.
- New behaviour needs a test. `pkg/certificate` mints its own certificates rather than checking in fixtures, so a chain with the shape you need is a few lines away; see `serverChain` in `connect_test.go`.

## Things worth knowing about the codebase

- `View()` is pure: it never mutates the model. Resizing and re-rendering go in `Update`, via `resizeComponents()` and `refreshViewportContent()`.
- Key bindings go through `internal/model/keys.go`, which also generates the `?` overlay.
- `pkg/certificate` never writes to stderr by default; a stray line corrupts the TUI. Its logger is a no-op until the app sets one.
- The `--json` contract in `pkg/certificate/report.go` is a separate translation layer, not json tags on internal structs. `TrustLevel` and `ChainProblem` are iota constants and must not leak as numbers. Only strings, timestamps and bools cross it, and slices marshal as `[]`, never `null`.

## Reporting a bug

Attach the certificate if you can. `y509 export` writes one out, and a chain from a public server is public data.

## Adding a trust store snapshot

Add it to the pinned lists at the top of `scripts/gen_trust_stores.go` and run `make trust-stores`. Commit `internal/truststore/data` as generated; `PROVENANCE.md` there records each source's URL, version, date and SHA-256. A source whose licence does not allow redistributing the certificates gets fingerprints only, as OpenJDK does.

## Adding a STARTTLS protocol

Write a `func(net.Conn) error` prelude in `pkg/certificate/connect.go` and add it to `startTLSNegotiators` and `StartTLSProtocols`. The `--starttls` help and the "unsupported protocol" error update themselves.

Test it against a fake server over `net.Pipe`, including the awkward cases: a multi-line greeting, an untagged response, a refusal.
