external

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package external reads Truestamp's keyring, /.well-known/keyring.json, for the keys commands (keys list, keys get and keys current). The verifier of `truestamp verify` reads and loads its keyring itself, in internal/verifier and internal/verifier/keyring. A keyring's bytes are read through internal/strictjson, the reader of SPEC.md section 10.1 (Parsing) that every keyring a verifier loads goes through (section 10.2, step 0), so a body that breaks any of its rules is not a keyring:

  • J1: a body over MAX_READ_OCTETS octets;
  • J2: a body that begins with a byte order mark, or has content after its value;
  • J3: invalid UTF-8 anywhere in the body, or an escaped lone surrogate;
  • J4: an object, at any depth, that repeats a member name;
  • J5: a number that overflows binary64, or whose value is an integer of magnitude above MAX_INTEGER and below 10^21, in any member, read or not;
  • J6: nesting deeper than MAX_DEPTH.

Member names match exactly, case included: only keys and version name the keyring's members, and only key_id, public_key, sequence and active a key's, so a member named in another case (KEYS, KEY_ID, Active) is a member of no keyring and is ignored. A sequence is read by its value, so an integral spelling of it (1.0, 1e0) is that integer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyringKey

type KeyringKey struct {
	KeyID     string `json:"key_id"`
	PublicKey string `json:"public_key"`
	Sequence  int    `json:"sequence"`
	Active    bool   `json:"active"`
}

KeyringKey is a single entry in the keyring.

type KeyringResponse

type KeyringResponse struct {
	Version string       `json:"version"`
	Keys    []KeyringKey `json:"keys"`
}

KeyringResponse is the shape of /.well-known/keyring.json.

func FetchKeyring added in v0.13.0

func FetchKeyring(keyringURL string) (*KeyringResponse, error)

FetchKeyring retrieves and decodes the keyring document at keyringURL. A transport failure or a non-2xx status is an error that keeps the httpclient typing beneath a friendly message, and a body that is not a keyring is a MalformedResponseError.

Trust model: the keyring's authenticity is rooted entirely in the TLS chain presented by keyringURL. There is no in-band signature over the keyring payload itself, so every key in the returned document is only as trustworthy as the URL you configured. In particular:

  • Use https:// with a host whose certificate chain you trust (an attacker able to mint a valid cert for the host, via DNS/BGP hijack, a rogue CA, or a compromised certificate, can substitute signing keys and every downstream signature will validate against their key).
  • The keyring URL is derived from --base-url (or TRUESTAMP_BASE_URL, or base_url in config.toml); set that origin from a source you trust, e.g. official Truestamp docs, not from a bundle authored by the same party whose proof you are verifying.
  • The CLI enforces TLS chain validation (InsecureSkipVerify is never set) and refuses any redirect that downgrades https to http, so a server cannot talk the fetch out of TLS mid-chain (httpclient.ErrRedirectDowngrade). Cross-host redirects that stay on https ARE followed, they remain authenticated by the CA chain, and banning them would break the GitHub-asset fetch in internal/selfupgrade, which shares this client.

A future revision may add pinning of the keyring payload's hash or a cosign/Sigstore signature over the keyring document itself. Until then, treat the configured base URL as a root of trust that deserves the same care as a CA root.

func ParseKeyring added in v0.13.0

func ParseKeyring(body []byte) (*KeyringResponse, error)

ParseKeyring decodes a keyring document through the strict reader. A body without a `keys` list is not a keyring at all (a captive portal, a CDN stub) and is malformed, never a keyring that publishes no key.

func (*KeyringResponse) Active added in v0.14.0

func (k *KeyringResponse) Active() (KeyringKey, bool)

Active returns the entry the keyring marks as signing right now.

func (*KeyringResponse) FindByID added in v0.14.0

func (k *KeyringResponse) FindByID(keyID string) (KeyringKey, bool)

FindByID returns the entry with the given key id. The id is hex, so the comparison is case-insensitive. This is a lookup, not a binding: it answers "which entry has this id", never "is this key Truestamp's".

type MalformedResponseError added in v0.12.0

type MalformedResponseError struct {
	Source string
	Detail string
	Err    error
}

MalformedResponseError reports a 2xx response this client could not interpret as a keyring: a body the strict reader refuses, or a value that does not have a keyring's shape. Err, when set, is the reader's refusal.

func (*MalformedResponseError) Error added in v0.12.0

func (e *MalformedResponseError) Error() string

func (*MalformedResponseError) Unwrap added in v0.12.0

func (e *MalformedResponseError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL