Documentation
¶
Overview ¶
Package security provides TLS configuration, local address checking, and security helpers for gofly services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstantTimeEqual ¶
func IsLocalRemote ¶
Types ¶
type TLSConfig ¶
type TLSConfig struct {
CertFile string `json:"certFile,omitempty"`
KeyFile string `json:"keyFile,omitempty"`
// CAFile is the CA bundle used to verify the peer certificate. On a client
// it verifies the server; on a server in mutual mode it may also verify the
// client when ClientCAFile is empty.
CAFile string `json:"caFile,omitempty"`
// ClientCAFile, when set on a server, turns on mutual TLS and verifies
// client certificates against this CA bundle.
ClientCAFile string `json:"clientCAFile,omitempty"`
// ServerName overrides the SNI / verification hostname on a client.
ServerName string `json:"serverName,omitempty"`
// InsecureSkipVerify disables peer verification on a client. Use only for
// local development.
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
// MinVersion optionally pins the minimum TLS version (e.g. tls.VersionTLS13).
MinVersion uint16 `json:"minVersion,omitempty"`
}
TLSConfig describes the TLS/mTLS material for a server or client.
CertFile/KeyFile carry the local identity. CAFile lets a client (or a server in mutual mode) verify the peer certificate chain against a custom CA bundle. ClientCAFile is server-only and, when set, enables mutual TLS by requiring and verifying client certificates against the given CA bundle.
func (TLSConfig) ClientTLSConfig ¶
ClientTLSConfig builds a *tls.Config for a TLS/mTLS client. It returns nil (and no error) when no CA, client certificate, ServerName or skip-verify flag is configured, letting callers fall back to plaintext.
func (TLSConfig) MutualEnabled ¶
MutualEnabled reports whether the server should require and verify client certificates (mutual TLS).