Documentation
¶
Overview ¶
Package client builds a configured cinc-api client from CLI configuration. It is the single seam between cinc CLI state and the server API library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Explain ¶ added in v0.24.0
Explain rewrites the transport failures a user can fix themselves (a server certificate no trusted CA signed, a server that isn't listening, a host name that doesn't resolve) into a sentence that names the server and says what to check. Go's own text for these is a chain of package prefixes that buries both. Any other error, including every error the server itself returned, is returned unchanged.
func New ¶
New builds a cinc-api client from a resolved configuration profile. All server authentication and transport is handled by the cinc-api library; this function only loads the signing key and wires up the connection parameters.
func SilenceTLSWarning ¶
func SilenceTLSWarning() (restore func())
SilenceTLSWarning suppresses the "TLS verification disabled" warning until the returned restore func is called. `cinc config validate` uses it: it reports TLS posture as its own check, so the warning would be redundant in the report.
Types ¶
type TrustedCerts ¶ added in v0.24.0
type TrustedCerts struct {
// Dir is the directory the certificates were read from.
Dir string
// Pool is a copy of the system pool with every loaded certificate added.
Pool *x509.CertPool
// Loaded names the files (base names, sorted) that held at least one
// certificate.
Loaded []string
// Skipped names the *.crt / *.pem files that held no parseable
// certificate or could not be read. Normal commands ignore them;
// `cinc config validate` reports them.
Skipped []string
}
TrustedCerts is the result of loading a trusted_certs_dir: the cert pool to verify servers against, plus which files contributed to it.
func LoadTrustedCerts ¶ added in v0.24.0
func LoadTrustedCerts(dir string) (*TrustedCerts, error)
LoadTrustedCerts reads every *.crt and *.pem file in dir and adds the certificates they hold to a copy of the system cert pool (an empty pool when the system one is unavailable). Subdirectories and other files are ignored; a certificate file that holds nothing parseable is listed in Skipped rather than failing the load. The returned errors deliberately do not wrap fs.ErrNotExist or fs.ErrPermission, so the command layer never mistakes them for a missing client key.
func TrustedCertsFor ¶ added in v0.24.0
func TrustedCertsFor(p config.Profile) (*TrustedCerts, error)
TrustedCertsFor resolves and loads the profile's trusted certificates. It returns nil, nil when the profile trusts only the system pool: no trusted_certs_dir is configured and neither default directory exists. An explicitly configured directory that is missing or unreadable is an error.