grpctls

package
v0.0.0-...-a54a33a Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: AGPL-3.0 Imports: 12 Imported by: 18

Documentation

Overview

Package grpctls provides helper structs and functions for grpc dialing with TLS options.

This package is a work in progress and makes no API stability promises.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Creds

Creds creates a transport credentials for the configuration.

func Dial

func Dial(uri string, cfg ClientCfg, grpcOpts ...grpc.DialOption) (*grpc.ClientConn, error)

Dial is used for grpc client dialing

func DialContext

func DialContext(ctx context.Context, uri string, cfg ClientCfg, grpcOpts ...grpc.DialOption) (*grpc.ClientConn, error)

DialContext is used for grpc client dialing with context

func Listener

func Listener(uri string) (net.Listener, error)

Listener returns a valid listener server from an URI.

func ParseURI

func ParseURI(s string) (proto string, addr string, err error)

ParseURI parses uri strings used in structs, it returns protocol and address.

Types

type ClientCfg

type ClientCfg struct {
	// CertFile path to the client certificate
	CertFile string `json:"certfile,omitempty"`
	// KeyFile path to the private key
	KeyFile string `json:"keyfile,omitempty"`
	// ServerName is used for server check validation
	ServerName string `json:"servername,omitempty"`
	// ServerCert path to the server certificate
	ServerCert string `json:"servercert,omitempty"`
	// CACert path to certification authority certificate
	CACert string `json:"cacert,omitempty"`
	// UseSystemCAs if client uses system wide CA certs
	UseSystemCAs bool `json:"systemca"`
}

ClientCfg defines configuration for a client.

func (ClientCfg) Empty

func (cfg ClientCfg) Empty() bool

Empty returns true if configuration values are empty.

func (ClientCfg) UseTLS

func (cfg ClientCfg) UseTLS() bool

UseTLS returns true if TLS configuration is set.

func (ClientCfg) Validate

func (cfg ClientCfg) Validate() error

Validate if configuration is ok.

type ServerCfg

type ServerCfg struct {
	// CertFile path to the server certificate
	CertFile string
	// KeyFile path to the private key
	KeyFile string
	// CACert path to certification authority certificate
	CACert string
	// ClientAuth if client certificate is required
	ClientAuth bool
}

ServerCfg defines configuration for a server.

func (ServerCfg) UseTLS

func (cfg ServerCfg) UseTLS() bool

UseTLS returns true if TLS configuration is set.

func (ServerCfg) Validate

func (cfg ServerCfg) Validate() error

Validate if configuration is ok.

Jump to

Keyboard shortcuts

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