Documentation
¶
Overview ¶
Package server contains the gRPC server implementation.
Copyright (c) Ultraviolet SPDX-License-Identifier: Apache-2.0
Index ¶
- Variables
- func BuildMTLSDescription(serverCAFile, clientCAFile string) string
- func ConfigureCertificateAuthorities(tlsConfig *tls.Config, serverCAFile, clientCAFile string) (bool, error)
- func ConfigureClientCA(tlsConfig *tls.Config, clientCAFile string) (bool, error)
- func ConfigureRootCA(tlsConfig *tls.Config, serverCAFile string) error
- func LoadCertFile(certFile string) ([]byte, error)
- func LoadX509KeyPair(certfile, keyfile string) (tls.Certificate, error)
- func ReadFileOrData(input string) ([]byte, error)
- func StopHandler(ctx context.Context, cancel context.CancelFunc, logger *slog.Logger, ...) error
- type AgentConfig
- type BaseServer
- type Config
- type Server
- type ServerConfig
- type ServerConfiguration
- type TLSSetupResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrAppendServerCA = errors.New("failed to append server ca to tls.Config") ErrAppendClientCA = errors.New("failed to append client ca to tls.Config") )
Functions ¶
func BuildMTLSDescription ¶
BuildMTLSDescription builds a description string for mTLS configuration.
func ConfigureCertificateAuthorities ¶
func ConfigureCertificateAuthorities(tlsConfig *tls.Config, serverCAFile, clientCAFile string) (bool, error)
ConfigureCertificateAuthorities configures both root and client CAs for the TLS config Returns true if mTLS should be enabled (client CA is configured).
func ConfigureClientCA ¶
ConfigureClientCA configures the client CA certificates for the TLS config Returns true if client CA was configured, false otherwise.
func ConfigureRootCA ¶
ConfigureRootCA configures the root CA certificates for the TLS config.
func LoadCertFile ¶
LoadCertFile loads certificate data from file path or returns empty byte slice if path is empty.
func LoadX509KeyPair ¶
func LoadX509KeyPair(certfile, keyfile string) (tls.Certificate, error)
LoadX509KeyPair loads X.509 key pair from certificate and key files or data.
func ReadFileOrData ¶
ReadFileOrData reads data from file if input looks like a file path, otherwise treats input as raw data.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
ServerConfig
AttestedTLS bool `env:"ATTESTED_TLS" envDefault:"false"`
}
func (AgentConfig) GetBaseConfig ¶
func (a AgentConfig) GetBaseConfig() ServerConfig
type BaseServer ¶
type BaseServer struct {
Ctx context.Context
Cancel context.CancelFunc
Name string
Address string
Config ServerConfiguration
Logger *slog.Logger
Protocol string
}
func NewBaseServer ¶
func NewBaseServer( ctx context.Context, cancel context.CancelFunc, name string, config ServerConfiguration, logger *slog.Logger, ) BaseServer
type Config ¶
type Config struct {
Host string `env:"HOST" envDefault:"localhost"`
Port string `env:"PORT" envDefault:"7001"`
ServerCAFile string `env:"SERVER_CA_CERTS" envDefault:""`
CertFile string `env:"SERVER_CERT" envDefault:""`
KeyFile string `env:"SERVER_KEY" envDefault:""`
ClientCAFile string `env:"CLIENT_CA_CERTS" envDefault:""`
}
type ServerConfig ¶
type ServerConfig struct {
Config
}
func (ServerConfig) GetBaseConfig ¶
func (s ServerConfig) GetBaseConfig() ServerConfig
type ServerConfiguration ¶
type ServerConfiguration interface {
GetBaseConfig() ServerConfig
}
type TLSSetupResult ¶
TLSSetupResult contains the result of TLS configuration setup.
func SetupRegularTLS ¶
func SetupRegularTLS(certFile, keyFile, serverCAFile, clientCAFile string) (*TLSSetupResult, error)
SetupRegularTLS sets up TLS configuration using regular certificates.