Documentation
¶
Overview ¶
Package certstore provides a Caddy v2 HTTP transport module that enables client certificate authentication using certificates from OS certificate stores (macOS Keychain and Windows Certificate Store) for mTLS connections to upstream servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertSelector ¶
type CertSelector struct {
// Pattern is the regex pattern to match against the certificate field.
// Required. Use anchors (^, $) for exact matches, e.g., "^exact\.match$"
Pattern string `json:"pattern"`
// Field specifies which certificate field to match against.
// Valid values: "subject" (default), "issuer", "serial", "dns_names"
Field string `json:"field,omitempty"`
// Location specifies which certificate store to use.
// On Windows: "user" (CurrentUser) or "machine" (LocalMachine)
// On macOS: "user" or "system" (no effect - Keychain searches both automatically)
Location string `json:"location,omitempty"`
// contains filtered or unexported fields
}
CertSelector specifies criteria for selecting a certificate from the store.
func (*CertSelector) UnmarshalCaddyfile ¶
func (cs *CertSelector) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
type HTTPTransport ¶
type HTTPTransport struct {
// Embed the standard HTTP transport
*reverseproxy.HTTPTransport
// ClientCert specifies the criteria for selecting a client
// certificate from the OS certificate store for mTLS authentication.
ClientCert *CertSelector `json:"client_certificate,omitempty"`
}
HTTPTransport wraps reverseproxy.HTTPTransport to provide client certificate authentication using certificates from OS certificate stores (macOS Keychain, Windows Certificate Store) for mTLS connections to upstream servers.
func (HTTPTransport) CaddyModule ¶
func (h HTTPTransport) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*HTTPTransport) Cleanup ¶
func (h *HTTPTransport) Cleanup() error
Cleanup implements caddy.CleanerUpper. It closes any idle connections and decrements the reference count for the cached certificate. When the reference count reaches zero, the certificate's OS resources are freed.
func (*HTTPTransport) Provision ¶
func (h *HTTPTransport) Provision(ctx caddy.Context) error
Provision sets up the HTTP transport by loading the client certificate from the OS certificate store based on the configured matcher criteria. It compiles regex patterns if needed and validates the certificate exists.
func (*HTTPTransport) UnmarshalCaddyfile ¶
func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error