https

package
v0.0.0-...-98f0a1a Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP01    challenge = "http-01"
	TLSAlpn01 challenge = "tlsalpn-01"
)

Variables

This section is empty.

Functions

func IssueCertificates

func IssueCertificates(cacheDir, email, challengeType string, domains []string, useProduction bool, altHTTPPort, altTLSAlpnPort int, log *zap.Logger) (*tls.Config, error)

Types

type AcmeConfig

type AcmeConfig struct {
	// directory to save the certificates, le_certs default
	CacheDir string `mapstructure:"cache_dir" json:"cache_dir,omitempty" bson:"cache_dir,omitempty"`

	// User email, mandatory
	Email string `mapstructure:"email" json:"email,omitempty" bson:"email,omitempty"`

	// supported values: http-01, tlsalpn-01
	ChallengeType string `mapstructure:"challenge_type" json:"challenge_type,omitempty" bson:"challenge_type,omitempty"`

	// The alternate port to use for the ACME HTTP challenge
	AltHTTPPort int `mapstructure:"alt_http_port" json:"alt_http_port,omitempty" bson:"alt_http_port,omitempty"`

	// The alternate port to use for the ACME TLS-ALPN
	AltTLSALPNPort int `mapstructure:"alt_tlsalpn_port" json:"alt_tlsalpn_port,omitempty" bson:"alt_tlsalpn_port,omitempty"`

	// Use LE production endpoint or staging
	UseProductionEndpoint bool `mapstructure:"use_production_endpoint" json:"use_production_endpoint,omitempty" bson:"use_production_endpoint,omitempty"`

	// Domains to obtain certificates
	Domains []string `mapstructure:"domains" json:"domains,omitempty" bson:"domains,omitempty"`
}

func (*AcmeConfig) InitDefaults

func (ac *AcmeConfig) InitDefaults() error

type ClientAuthType

type ClientAuthType string
const (
	NoClientCert               ClientAuthType = "no_client_cert"
	RequestClientCert          ClientAuthType = "request_client_cert"
	RequireAnyClientCert       ClientAuthType = "require_any_client_cert"
	VerifyClientCertIfGiven    ClientAuthType = "verify_client_cert_if_given"
	RequireAndVerifyClientCert ClientAuthType = "require_and_verify_client_cert"
)

type HTTP2Config

type HTTP2Config struct {

	// H2C enables HTTP/2 over TCP
	H2C bool `mapstructure:"h2c" json:"h2c,omitempty" bson:"h2c,omitempty"`

	// MaxConcurrentStreams defaults to 128.
	MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams" json:"max_concurrent_streams,omitempty" bson:"max_concurrent_streams,omitempty"`
}

func (*HTTP2Config) EnableHTTP2

func (h2 *HTTP2Config) EnableHTTP2() bool

func (*HTTP2Config) InitDefaults

func (h2 *HTTP2Config) InitDefaults() error

type SSLConfig

type SSLConfig struct {
	// Address to listen as HTTPS server, defaults to 0.0.0.0:443.
	Address string `mapstructure:"address" json:"address,omitempty" bson:"address,omitempty"`

	// Acme configuration
	Acme *AcmeConfig `mapstructure:"acme" json:"acme,omitempty" bson:"acme,omitempty"`

	// Redirect when enabled forces all http connections to switch to https.
	Redirect bool `mapstructure:"redirect" json:"redirect,omitempty" bson:"redirect,omitempty"`

	// Key defined private server key.
	Key string `mapstructure:"key" json:"key,omitempty" bson:"key,omitempty"`

	// Cert is https certificate.
	Cert string `mapstructure:"cert" json:"cert,omitempty" bson:"cert,omitempty"`

	// RootCA file
	RootCA string `mapstructure:"root_ca" json:"root_ca,omitempty" bson:"root_ca,omitempty"`

	// AuthType mTLS auth
	AuthType ClientAuthType `mapstructure:"client_auth_type" json:"auth_type,omitempty" bson:"auth_type,omitempty"`

	// internal
	Port int
	// contains filtered or unexported fields
}

func (*SSLConfig) EnableACME

func (s *SSLConfig) EnableACME() bool

func (*SSLConfig) InitDefaults

func (s *SSLConfig) InitDefaults() error

func (*SSLConfig) Valid

func (s *SSLConfig) Valid() error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewHTTPSServer

func NewHTTPSServer(handler http.Handler, cfg *SSLConfig, cfgHTTP2 *HTTP2Config, errLog *log.Logger, sLog *slog.Logger, zapLog *zap.Logger) (*Server, error)

func (*Server) GetServer

func (s *Server) GetServer() *http.Server

func (*Server) Start

func (s *Server) Start(mdwr map[string]middleware.Middleware, order []string) error

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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