config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package config loads the SSLKnife configuration file and resolves platform-specific default locations.

Index

Constants

View Source
const (
	EnvConfig   = "SSLKNIFE_CONFIG"
	EnvDatabase = "SSLKNIFE_DATABASE"
	EnvDataDir  = "SSLKNIFE_DATA_DIR"
)

Environment variables that override file locations.

View Source
const (
	EnvVaultRoleID   = "SSLKNIFE_VAULT_ROLE_ID"
	EnvVaultSecretID = "SSLKNIFE_VAULT_SECRET_ID"
)

Environment variables for the Vault remote's AppRole login.

View Source
const RemoteVault = "vault"

Remote types.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the platform config file location:

Linux:   $XDG_CONFIG_HOME/sslknife/config.yaml (~/.config/...)
macOS:   ~/Library/Application Support/sslknife/config.yaml
Windows: %AppData%\sslknife\config.yaml

func DefaultDataDir

func DefaultDataDir() (string, error)

DefaultDataDir returns the platform data directory:

Linux:   $XDG_DATA_HOME/sslknife (~/.local/share/sslknife)
macOS:   ~/Library/Application Support/sslknife
Windows: %LocalAppData%\sslknife

func ExpandHome

func ExpandHome(p string) string

ExpandHome replaces a leading "~/" with the user's home directory.

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses Go durations plus d/w suffixes. "90d12h" is accepted.

Types

type CTConfig

type CTConfig struct {
	Enabled             bool     `yaml:"enabled"`
	Provider            string   `yaml:"provider"` // certspotter or crtsh
	Interval            Duration `yaml:"interval"`
	AutoWatchStoredSANs bool     `yaml:"auto_watch_stored_sans"`
}

type Config

type Config struct {
	Database DatabaseConfig `yaml:"database"`
	Vault    VaultConfig    `yaml:"vault"`
	TLS      TLSConfig      `yaml:"tls"`
	CT       CTConfig       `yaml:"ct"`
	Server   ServerConfig   `yaml:"server"`
	Expiry   ExpiryConfig   `yaml:"expiry"`
	Remote   RemoteConfig   `yaml:"remote"`
}

Config is the on-disk configuration. Secrets never belong here: the database password comes from the TTY, the OS keychain or the environment.

func Default

func Default() (*Config, error)

Default returns the built-in configuration.

func Load

func Load(path string, mustExist bool) (*Config, error)

Load reads path on top of the defaults. A missing file is not an error unless mustExist is set (the user passed --config explicitly).

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

Marshal renders the configuration as YAML.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks value ranges.

type DatabaseConfig

type DatabaseConfig struct {
	Path string `yaml:"path"`
}

type Duration

type Duration time.Duration

Duration is a time.Duration that also accepts day ("d") and week ("w") units, e.g. "30d" or "2w", in addition to Go duration syntax.

func (Duration) D

func (d Duration) D() time.Duration

D returns the value as a time.Duration.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (any, error)

MarshalYAML renders the duration in Go syntax.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements yaml.Unmarshaler for scalar values.

type ExpiryConfig

type ExpiryConfig struct {
	WarningDays  int `yaml:"warning_days"`
	CriticalDays int `yaml:"critical_days"`
}

type RemoteConfig

type RemoteConfig struct {
	// Type is "" (no remote) or "vault".
	Type      string `yaml:"type"`
	Address   string `yaml:"address,omitempty"`   // default $VAULT_ADDR
	Namespace string `yaml:"namespace,omitempty"` // default $VAULT_NAMESPACE
	CACert    string `yaml:"ca_cert,omitempty"`   // default $VAULT_CACERT
	Mount     string `yaml:"mount"`               // KV version 2 mount
	Path      string `yaml:"path"`                // prefix inside the mount
	// AuthMethod is token, approle, userpass or ldap.
	AuthMethod   string `yaml:"auth_method"`
	AuthMount    string `yaml:"auth_mount,omitempty"` // default: the method name
	Username     string `yaml:"username,omitempty"`   // userpass/ldap login
	RoleID       string `yaml:"role_id,omitempty"`    // approle
	SecretIDFile string `yaml:"secret_id_file,omitempty"`
	TokenFile    string `yaml:"token_file,omitempty"` // default ~/.vault-token
	// TransitKey, when set, encrypts private keys with this Vault Transit
	// key before they are stored in KV.
	TransitKey   string `yaml:"transit_key,omitempty"`
	TransitMount string `yaml:"transit_mount,omitempty"` // default transit
	// AutoSync syncs before and after every command that opens the vault.
	AutoSync bool `yaml:"auto_sync"`
	// Interval is how often `sslknife server` syncs.
	Interval Duration `yaml:"interval"`
}

RemoteConfig shares the inventory between devices through HashiCorp Vault. Tokens and AppRole secret IDs never belong here: they come from $VAULT_TOKEN, the OS keychain (`sslknife remote login`), a token file or $SSLKNIFE_VAULT_SECRET_ID / secret_id_file.

func (RemoteConfig) Enabled

func (r RemoteConfig) Enabled() bool

Enabled reports whether a remote is configured.

type ServerConfig

type ServerConfig struct {
	Listen string `yaml:"listen"`
	// RefreshInterval is how often known TLS endpoints are re-inspected
	// by the server (0 disables).
	RefreshInterval Duration `yaml:"refresh_interval"`
}

type TLSConfig

type TLSConfig struct {
	Timeout     Duration `yaml:"timeout"`
	Concurrency int      `yaml:"concurrency"`
	Proxy       string   `yaml:"proxy,omitempty"`
}

type VaultConfig added in v0.2.0

type VaultConfig struct {
	// UnlockCache keeps the vault unlocked in a background process for this
	// long after its last use, once a password or Touch ID unlocked it
	// (0 disables).
	UnlockCache Duration `yaml:"unlock_cache"`
}

Jump to

Keyboard shortcuts

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