acme4netvs

package module
v2.0.0-...-1375d5b Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 25 Imported by: 0

README

ACME client hooks for SCC NETVS

Releases

Precompiled binaries are released as GitLab releases, a list of permalinks to the newest version is given here. If binaries for your platform are not included, feel free to open an issue to get them included in future releases.

Documentation

Documentation is available on this website (currently only in English).

Documentation

Index

Constants

View Source
const (
	DNSWaitTimeoutMin = time.Second * 5
	DNSWaitBetweenMin = time.Second * 1
)
View Source
const (
	FormatNSHasChallenge            = "✅ [%s] Challenge is available on %s (after %s)"
	FormatExecutionInfo             = "✨ Running hook %s, version %s"
	FormatAPITokenSource            = "✨ Using NETVS API token from %s"
	FormatClientFromIni             = "✨ Using config file %s"
	FormatWaitingForChallenges      = "✨ Waiting for %d parallel nameserver checks"
	FormatNewGoroutineForFQDN       = "✨ [%s] Started new goroutine to check DNS challenge on %s"
	FormatNSList                    = "✨ [%s] has nameservers %s"
	FormatGenericInfo               = "✨ [%s] %s"
	FormatNewAcmeTxtInfo            = "✨ [%s] Creating new TXT record _acme-challenge.%s: %s"
	FormatChallengeCleanedUp        = "👍 [%s] Removed challenge %s"
	FormatDNSChecksDone             = "👍 [%s] Nameserver checks are done"
	FormatDNSWaitAfterChecksWaiting = "✨ Waiting %s after successful DNS checks"
	FormatConfigfileCantOpen        = "👎 Unable to open config file %s, skipping file: %s"
	FormatCommandNotImplemented     = "👎 operation »%s« is not implemented in this plugin"
	FormatEmptyDomain               = "💀 CERTBOT_DOMAIN is empty"
	FormatConfigfileNoneFound       = "💀 Unable to find a suitable config file"
	FormatConfigfileParseError      = "💀 Unable to parse config file %s: %s"
	FormatUnknownEndpoint           = "💀 Unknown endpoint %s"
	FormatMissingCommand            = "💀 Missing command. See --help for details."
	FormatEmptyValidation           = "💀 [%s] CERTBOT_VALIDATION is empty"
	FormatDNSCheckTimeout           = "💀 [%s] DNS check on nameserver »%s« timed out after %s"
	FormatChallengeDeployment       = "💀 [%s] Error deploying challenge. API error: »%s«"
	FormatUnableToFindNS            = "💀 [%s] Error looking up nameserver for domain %s: %s"
	FormatChallengeCleanup          = "💀 [%s] Error removing challenge. API error: »%s«"
	FormatNoNSforDomain             = "💀 [%s] Unable to find any nameserver for domain %s"
	FormatDurationTooSmall          = "💀 Duration value for %s is too small (%s < %s). Did you omit a time unit?"
	FormatNSDoesNotHaveChallenge    = "🔧️ [%s] Challenge is NOT yet available on %s"
	FormatNETVSClientCreated        = "🚀 NETVS client created (baseURI: »%s«, apiVersion: »%s«)"
	FormatHasChallengePrefix        = "⁉️ Domain »%s« has prefix »_acme-challenge.«. Please check the way you're calling acme4netvs."
	FormatChallengePrefixRemoved    = "️💥 Removed prefix »_acme-challenge.« from domain »%s«. Please fix the way you're calling acme4netvs if possible."
)
View Source
const (
	CommonTextHelp = `` /* 255-byte string literal not displayed */

	CommonTextLatestRelease = `
Visit https://www.ca.kit.edu/p/software/acme4netvs to get the latest release.
`
)
View Source
const (
	DefaultAPIVersion = "3.2"
	URITemplate       = `https://%s/api/%s/wapi/transaction/execute`
	BASEURITEST       = "www-net-test.scc.kit.edu"
	BASEURIPROD       = "www-net.scc.kit.edu"
	BASEURIDEVEL      = "www-net-devel.scc.kit.edu"
)

Variables

View Source
var (
	ErrorNoNameserverFound = errors.New("unable to find nameserver for domain")
)

Functions

func CheckChallengeOnAllNS

func CheckChallengeOnAllNS(
	token string,
	fqdn string,
	globalTimeout time.Duration,
	waitTimeBetweenChecks time.Duration,
	waitTimeAfterChecks time.Duration,
	debugPrintf DebugPrintfFunc)

func CheckTimeoutValues

func CheckTimeoutValues(_ *cobra.Command, _ []string)

func CleanChallenge

func CleanChallenge(client *NETVSClient, fqdn string, token string, debugPrintf DebugPrintfFunc) error

func CommonDNSWaitFlags

func CommonDNSWaitFlags(rootCmd *cobra.Command)

func CommonGlobalFlags

func CommonGlobalFlags(appName string, rootCmd *cobra.Command)

func CommonViperSetup

func CommonViperSetup(commands ...*cobra.Command)

func CreateCertificateFQDN

func CreateCertificateFQDN(ta Transaction, fqdn string)

CreateCertificateFQDN creates Transaction which creates the FQDN we want a certificate for

func CreateChallengeFQDN

func CreateChallengeFQDN(ta Transaction, fqdn string)

CreateChallengeFQDN creates Transaction which creates the "_acme-challenge." FQDN

func CreateChallengeRecord

func CreateChallengeRecord(ta Transaction, fqdn string, token string)

CreateChallengeRecord creates Transaction which creates the "_acme-challenge." TXT record

func CreateFQDN

func CreateFQDN(ta Transaction, fqdn string, fqdnType string, description string)

CreateFQDN creates Transaction for a generic FQDN creation

func DebugPrintVersion

func DebugPrintVersion(printfFunc DebugPrintfFunc, version string)

func DeleteChallengeRecord

func DeleteChallengeRecord(ta Transaction, fqdn string, token string)

DeleteChallengeRecord creates Transaction which deletes the "_acme-challenge." TXT record

func DeployChallenge

func DeployChallenge(client *NETVSClient, fqdn string, token string, debugPrintf DebugPrintfFunc) error

func FinalizeViperSetup

func FinalizeViperSetup(rootCmd *cobra.Command)

func GetInformation

func GetInformation(ta Transaction, fqdn string, token string)

GetInformation creates a Transaction to get all information required for challenge response record creation

func HandleChallengePrefix

func HandleChallengePrefix(fqdn string, remove bool, debugPrintf DebugPrintfFunc) string

func InstallDebugHandler

func InstallDebugHandler() (string, chan string, error)

func NameserverHasChallenge

func NameserverHasChallenge(nameserver, fqdn, challenge string) bool

func NameserversForFQDN

func NameserversForFQDN(domain string) ([]string, error)

func ReaderToString

func ReaderToString(r io.Reader) string

Types

type AuthorizationError

type AuthorizationError error

type ClientConfig

type ClientConfig struct {
	ConfigDir            string
	ConfigFile           string
	APIToken             string
	Endpoint             string
	Quiet                bool
	WaitForDNS           bool
	DNSWaitTimeout       time.Duration
	DNSTimeBetweenChecks time.Duration
}

type DebugPrintfFunc

type DebugPrintfFunc func(format string, a ...any)

func MakeDebugFunc

func MakeDebugFunc(enable bool, writer io.Writer) DebugPrintfFunc

type DnsFqdn

type DnsFqdn struct {
	Description          string   `mapstructure:"description"`
	Gpk                  string   `mapstructure:"gpk"`
	HasRr                bool     `mapstructure:"has_rr"`
	IsDhcp               bool     `mapstructure:"is_dhcp"`
	IsEmptyNonterminal   bool     `mapstructure:"is_empty_nonterminal"`
	IsHost               bool     `mapstructure:"is_host"`
	IsNonterminal        bool     `mapstructure:"is_nonterminal"`
	IsOwn                bool     `mapstructure:"is_own"`
	IsWildcard           bool     `mapstructure:"is_wildcard"`
	Label                string   `mapstructure:"label"`
	ParentValue          string   `mapstructure:"parent_value"`
	RadType              uint     `mapstructure:"rad_type"`
	RrChainTargetBcdList []string `mapstructure:"rr_chain_target_bcd_list"`
	RrChainTargetIsOwn   bool     `mapstructure:"rr_chain_target_is_own"`
	SubFqdnCount         uint     `mapstructure:"sub_fqdn_count"`
	Type                 string   `mapstructure:"type"`
	Value                string   `mapstructure:"value"`
	ValueIDNA            string   `mapstructure:"value_idna"`
	Zone                 string   `mapstructure:"zone"`
}

type DnsRecord

type DnsRecord struct {
	Data                  string   `mapstructure:"data"`
	Fqdn                  string   `mapstructure:"fqdn"`
	FqdnDescription       string   `mapstructure:"fqdn_description"`
	FqdnType              string   `mapstructure:"fqdn_type"`
	Gpk                   string   `mapstructure:"gpk"`
	HostIsNws             bool     `mapstructure:"host_is_nws"`
	IsOwn                 bool     `mapstructure:"is_own"`
	TargetBcdList         []string `mapstructure:"target_bcd_list"`
	TargetDataUnref       string   `mapstructure:"target_data_unref"`
	TargetFqdn            string   `mapstructure:"target_fqdn"`
	TargetFqdnType        string   `mapstructure:"target_fqdn_type"`
	TargetIpaddr          string   `mapstructure:"target_ipaddr"`
	TargetIsReverseUnique bool     `mapstructure:"target_is_reverse_unique"`
	TargetIsSingleton     bool     `mapstructure:"target_is_singleton"`
	TTL                   int      `mapstructure:"ttl"`
	TTLResetDate          string   `mapstructure:"ttl_reset_date"`
	TTLResetDays          string   `mapstructure:"ttl_reset_days"`
	TTLZoneDefault        int      `mapstructure:"ttl_zone_default"`
	Type                  string   `mapstructure:"type"`
	Zone                  string   `mapstructure:"zone"`
}

type GetSessionToken

type GetSessionToken func() string

GetSessionToken returns a string containing a session token

type InternalServerError

type InternalServerError error

type InvalidRequest

type InvalidRequest error

type NETVSClient

type NETVSClient struct {
	NETVSConfig
	Client *http.Client
}

func BuildLocalNetVSClient

func BuildLocalNetVSClient(debugPrintf DebugPrintfFunc) *NETVSClient

func NewNETVSClient

func NewNETVSClient(config *NETVSConfig) *NETVSClient

NewNETVSClient creates a new NETVSClient that automatically adds authentication headers

func (*NETVSClient) ExecuteTA

func (c *NETVSClient) ExecuteTA(t Transaction) (TAResult, error)

type NETVSConfig

type NETVSConfig struct {
	BaseURI      string
	APIVersion   string
	SessionToken GetSessionToken
}

func CmdConfigFromAPIToken

func CmdConfigFromAPIToken(apiToken string, debugPrintf DebugPrintfFunc) (*NETVSConfig, error)

func CmdParseAllNETVSConfigs

func CmdParseAllNETVSConfigs(debugPrintf DebugPrintfFunc) (*NETVSConfig, error)

func CmdParseNETVSConfig

func CmdParseNETVSConfig(cfgPath string) (*NETVSConfig, error)

type NETVSCredentialINI

type NETVSCredentialINI struct {
	Endpoint string
	Sections map[string]NETVSCredentialSection
}

func ParseNETVSCredentialsINI

func ParseNETVSCredentialsINI(inicontents io.Reader) (*NETVSCredentialINI, error)

func (*NETVSCredentialINI) GetSections

func (c *NETVSCredentialINI) GetSections() []string

func (*NETVSCredentialINI) ToNETVSConfig

func (c *NETVSCredentialINI) ToNETVSConfig(endpoint, apiVersion string) *NETVSConfig

type NETVSCredentialSection

type NETVSCredentialSection struct {
	BaseURL string
	Token   string
}

type NetVSActionFunc

type NetVSActionFunc func(client *NETVSClient, fqdn string, token string, debugPrintf DebugPrintfFunc) error

type OtherUnexpectedResponseError

type OtherUnexpectedResponseError error

type TAResult

type TAResult []interface{}

func (TAResult) IsError

func (r TAResult) IsError() bool

func (TAResult) NumResults

func (r TAResult) NumResults() int

type TAStatement

type TAStatement struct {
	Name string             `json:"name"`
	Old  TAStatementDataMap `json:"old,omitempty"`
	New  TAStatementDataMap `json:"new,omitempty"`
}

TAStatement represents a single transaction statement

func (TAStatement) AsPart

func (taStatement TAStatement) AsPart() string

type TAStatementDataMap

type TAStatementDataMap map[string]interface{}

TAStatementDataMap is a typed map for members Old and New of TAStatement

type Transaction

type Transaction interface {
	// AsRequestBody returns the complete transaction as a string for the request body
	AsRequestBody() io.Reader
	// AddEntries appends transaction entries
	AddEntries(request ...TransactionEntry)
	// NumEntries returns the number of entries
	NumEntries() int
}

type TransactionEntry

type TransactionEntry interface {
	// AsPart returns a single request as json object for the transaction body
	AsPart() string
}

type TransactionList

type TransactionList []TransactionEntry

TransactionList holds the list of statements in a transaction. It implements the Transaction interface.

func NewTARequestBody

func NewTARequestBody() *TransactionList

NewTARequestBody creates an empty transactionList

func (*TransactionList) AddEntries

func (body *TransactionList) AddEntries(request ...TransactionEntry)

func (*TransactionList) AsRequestBody

func (body *TransactionList) AsRequestBody() io.Reader

func (*TransactionList) NumEntries

func (body *TransactionList) NumEntries() int

type UnexpectedNonTerminalTypeError

type UnexpectedNonTerminalTypeError error

Directories

Path Synopsis
_generators
cmd

Jump to

Keyboard shortcuts

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