credentials

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package credentials loads certificates and validates user credentials.

Index

Constants

This section is empty.

Variables

View Source
var (

	// TargetName is a flag containing the hostname verfified by TLS handshake.
	TargetName = flag.String("target_name", "", "The target name used to verify the hostname returned by TLS handshake")
)

Functions

func AttachToContext

func AttachToContext(ctx context.Context) context.Context

AttachToContext attaches credentials to a context. If there are existing credentials, it overrides their values.

func AuthorizeUser

func AuthorizeUser(ctx context.Context) (string, bool)

AuthorizeUser checks for valid credentials in the context Metadata.

func CheckCertSANData

func CheckCertSANData(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

Extract the client certification from a known location and compare it to the SAN of the client certificate. return nil if cannot open the file or it pass SAN test. return error else

func ClientCredentials

func ClientCredentials() []grpc.DialOption

ClientCredentials generates gRPC DialOptions for existing credentials.

func GetCAEntity

func GetCAEntity() *entity.Entity

GetCAEntity gets a CA entity from a CA file and private key.

func LoadCertificates

func LoadCertificates() ([]tls.Certificate, *x509.CertPool)

LoadCertificates loads certificates from files and exits if there's an error.

func ParseCertificates

func ParseCertificates() (*tls.Certificate, *x509.Certificate)

ParseCertificates gets certificates from files or generates them from the CA.

func ServerCredentials

func ServerCredentials() []grpc.ServerOption

ServerCredentials generates gRPC ServerOptions for existing credentials.

func SetTargetName

func SetTargetName(name string)

SetTargetName sets the targetName variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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