Documentation ¶
Overview ¶
Package credentials loads certificates and validates user credentials.
Index ¶
- Variables
- func AttachToContext(ctx context.Context) context.Context
- func AuthorizeUser(ctx context.Context) (string, bool)
- func CheckCertSANData(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
- func ClientCredentials() []grpc.DialOption
- func GetCAEntity() *entity.Entity
- func LoadCertificates() ([]tls.Certificate, *x509.CertPool)
- func ParseCertificates() (*tls.Certificate, *x509.Certificate)
- func ServerCredentials() []grpc.ServerOption
- func SetTargetName(name string)
Constants ¶
This section is empty.
Variables ¶
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 ¶
AttachToContext attaches credentials to a context. If there are existing credentials, it overrides their values.
func AuthorizeUser ¶
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 ¶
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.
Types ¶
This section is empty.