tls

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: BSD-3-Clause Imports: 14 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextValue

func ContextValue(c *Config) cli.Action

func SourceAnnotation

func SourceAnnotation() (string, string)

SourceAnnotation gets the name and value of the annotation added to the Data of all flags that are initialized from this package

Types

type Action added in v0.12.0

type Action = cli.Action

Action provides a context action that affects the TLS configuration

func FlagsAndArgs

func FlagsAndArgs() Action

func IDAnnotation added in v0.13.0

func IDAnnotation(id ID) Action

func ListCiphers

func ListCiphers() Action

func ListCurves

func ListCurves() Action

func SetCACertFile

func SetCACertFile(path ...string) Action

func SetCACertPath

func SetCACertPath(path ...string) Action

func SetCiphers

func SetCiphers(v ...CipherSuites) Action

func SetClientCertFile

func SetClientCertFile(path ...string) Action

func SetCurves

func SetCurves(v ...CurveIDs) Action

func SetInsecureKeyLogFile added in v0.9.0

func SetInsecureKeyLogFile(s ...*cli.File) Action

func SetInsecureSkipVerify

func SetInsecureSkipVerify(v ...bool) Action

func SetKeyFile

func SetKeyFile(path ...string) Action

func SetNextProtos

func SetNextProtos(s ...[]string) Action

func SetRandom added in v0.9.0

func SetRandom(r ...*cli.File) Action

func SetServerName

func SetServerName(s ...string) Action

func SetTLSv1

func SetTLSv1() Action

func SetTLSv1_0

func SetTLSv1_0() Action

func SetTLSv1_1

func SetTLSv1_1() Action

func SetTLSv1_2

func SetTLSv1_2() Action

func SetTLSv1_3

func SetTLSv1_3() Action

func SetTime

func SetTime(s ...*cli.File) Action

type CipherSuites

type CipherSuites []uint16

func (*CipherSuites) Set

func (c *CipherSuites) Set(arg string) error

func (*CipherSuites) String

func (c *CipherSuites) String() string

func (*CipherSuites) Synopsis

func (c *CipherSuites) Synopsis() string

type Config

type Config struct {
	*gotls.Config
	cli.Action
}

Config reepresents TLS configuration plus a default action.

func FromContext

func FromContext(ctx context.Context) *Config

FromContext obtains the server from the context.

func New

func New(opts ...Option) *Config

New creates a new TLS configuration. By default, it is also initialized with a default action that registers useful flags.

func (*Config) Apply

func (c *Config) Apply(opts ...Option)

func (*Config) Pipeline added in v0.7.3

func (c *Config) Pipeline() cli.Action

type CurveIDs

type CurveIDs []tls.CurveID

func (*CurveIDs) Set

func (c *CurveIDs) Set(arg string) error

func (*CurveIDs) String

func (c *CurveIDs) String() string

func (*CurveIDs) Synopsis

func (c *CurveIDs) Synopsis() string

type ID added in v0.13.0

type ID int

ID identifies each of the flags and args registered by FlagsAndArgs

const (
	IDCACertFile ID
	IDCACertPath
	IDCiphers
	IDClientCertFile
	IDCurves
	IDInsecureKeyLogFile
	IDInsecureSkipVerify
	IDKeyFile
	IDListCiphers
	IDListCurves
	IDNextProtos
	IDRandom
	IDServerName
	IDTime
	IDTLSv1
	IDTLSv1_0
	IDTLSv1_1
	IDTLSv1_2
	IDTLSv1_3
)

Various identifiers for flags and args registered by the package

func LookupID added in v0.13.0

func LookupID(target any) (ID, bool)

LookupID gets the identity of a flag or arg registered by FlagsAndArgs, if present.

func (ID) MarshalText added in v0.13.0

func (i ID) MarshalText() ([]byte, error)

MarshalText provides the implementation of encoding.TextMarshaler

func (ID) String added in v0.13.0

func (i ID) String() string

func (*ID) UnmarshalText added in v0.13.0

func (i *ID) UnmarshalText(data []byte) error

UnmarshalText provides the implementation of encoding.TextUnarshaler

type Option

type Option func(*Config) error

Option provides an option to the TLS configuration

func AddCertificate added in v0.7.2

func AddCertificate(cert gotls.Certificate) Option

AddCertificate adds a certificate to the pool

func AddRootCACertFile added in v0.7.2

func AddRootCACertFile(filename string) Option

AddRootCACertFile adds a CA certificate to the pool

func AddRootCACertPath added in v0.7.2

func AddRootCACertPath(path string) Option

AddRootCACertPath adds a search path to the CA certificate pool

func AddX509KeyPair added in v0.7.2

func AddX509KeyPair(certFile, keyFile string) Option

AddX509KeyPair adds a certificate to the pool

func WithAction added in v0.7.3

func WithAction(a cli.Action) Option

WithAction sets the action

func WithCiphers

func WithCiphers(ids CipherSuites) Option

WithCiphers sets up cipher suites

func WithCurves

func WithCurves(ids CurveIDs) Option

WithCurves sets up curves

func WithDefaultAction added in v0.7.3

func WithDefaultAction() Option

WithDefaultAction sets the action to the default

func WithInsecureSkipVerify

func WithInsecureSkipVerify(v bool) Option

WithInsecureSkipVerify sets up the option to skip verification in TLS handshake. This option is insecure.

func WithKeyLogWriter added in v0.9.0

func WithKeyLogWriter(w io.Writer) Option

WithKeyLogWriter sets the KeyLogWriter for debugging TLS connections. This option is insecure and should only be used for debugging purposes.

func WithNextProtos

func WithNextProtos(s []string) Option

WithNextProtos sets next protos

func WithRand added in v0.9.0

func WithRand(r io.Reader) Option

WithRand sets the random reader for TLS

func WithServerName

func WithServerName(s string) Option

WithServerName sets the server name

func WithTimeHelper

func WithTimeHelper(f *cli.File) Option

WithTimeHelper specifies the file whose modtime contains the time for the server

func (Option) Execute

func (o Option) Execute(c context.Context) error

Jump to

Keyboard shortcuts

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