credentials

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCServerCredentials

func GRPCServerCredentials(o *TLSServerConfig) ([]grpc.ServerOption, error)

GRPCServerCredentials returns grpc.ServerOption according to the given credential config.

func NewTLSConfig

func NewTLSConfig(opts ...TLSConfigOpts) (*tls.Config, error)

Types

type TLSClientConfig

type TLSClientConfig struct {
	TLSConfigBase

	// Skip verifying server cert
	SkipVerifyServer bool

	// To verify the server hostname
	ServerName string
}

func (*TLSClientConfig) VerifyServer

func (o *TLSClientConfig) VerifyServer() TLSConfigOpts

VerifyServer applies server verification settings on tls.Config.

type TLSConfigBase

type TLSConfigBase struct {
	// Disable TLS
	NoTLS bool

	// Path to the cert file
	CrtPath string

	// Path to the private key file
	KeyPath string

	// Path to the CA cert file
	CACrtPath string

	// CertData holds PEM-encoded bytes (typically read from a client certificate file).
	// CertData takes precedence over CrtPath
	CrtData []byte

	// KeyData holds PEM-encoded bytes (typically read from a client certificate key file).
	// KeyData takes precedence over KeyPath
	KeyData []byte

	// CACrtData holds PEM-encoded bytes (typically read from a root certificates bundle).
	// CACrtData takes precedence over CACrtPath
	CACrtData []byte
}

func (*TLSConfigBase) Certificates

func (o *TLSConfigBase) Certificates(required bool) TLSConfigOpts

Certificates sets certificate to tls.Config by loading cert key-pairs from files.

type TLSConfigOpts

type TLSConfigOpts func(c *tls.Config) error

type TLSServerConfig

type TLSServerConfig struct {
	TLSConfigBase

	// ClientAuth specifies how to handle client cert
	ClientAuth tls.ClientAuthType
}

func (*TLSServerConfig) VerifyClient

func (o *TLSServerConfig) VerifyClient() TLSConfigOpts

VerifyClient applies client certificate verification settings on tls.Config.

Jump to

Keyboard shortcuts

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