ca

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTrustCrtsDirEmpty trust certs dir is empty
	ErrTrustCrtsDirEmpty = errors.New("trust certs dir is empty")
)

Functions

func GetTLSConfig

func GetTLSConfig(certPemPath, certKeyPath string, caPaths, caCerts []string,
	encCertPemPath, encCertKeyPath string) (*cmtls.Config, error)

GetTLSConfig 根据传入的参数,构建tls.Config对象 @param certPemPath @param certKeyPath @param caPaths @param caCerts @param encCertPemPath @param encCertKeyPath @return *cmtls.Config @return error

func NewTLSListener

func NewTLSListener(inner net.Listener, config *cmtls.Config) net.Listener

NewTLSListener 根据tls配置,新建net.Listener对象 @param inner @param config @return net.Listener

Types

type CAClient

type CAClient struct {
	ServerName string
	CaPaths    []string
	CaCerts    []string
	CertFile   string
	KeyFile    string
	CertBytes  []byte
	KeyBytes   []byte
	Logger     log.LoggerInterface

	//for gmtls1.1
	EncCertFile  string
	EncKeyFile   string
	EncCertBytes []byte
	EncKeyBytes  []byte
}

CAClient CA客户端对象

func (*CAClient) GetCredentialsByCA

func (c *CAClient) GetCredentialsByCA() (*credentials.TransportCredentials, error)

GetCredentialsByCA 获得TransportCredentials对象 @return *credentials.TransportCredentials @return error

type CAServer

type CAServer struct {
	CaPaths  []string
	CaCerts  []string
	CertFile string
	KeyFile  string
	Logger   log.LoggerInterface
}

CAServer CA服务端对象

func (*CAServer) GetCredentialsByCA

func (s *CAServer) GetCredentialsByCA(checkClientAuth bool, customVerify CustomVerify) (
	*credentials.TransportCredentials, error)

GetCredentialsByCA 获得服务端的TransportCredentials对象 @param checkClientAuth @param customVerify @return cert @return err

type CustomVerify added in v2.1.0

type CustomVerify struct {
	VerifyPeerCertificate   func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
	GMVerifyPeerCertificate func(rawCerts [][]byte, verifiedChains [][]*cmx509.Certificate) error
}

CustomVerify 自定义验证模式

Jump to

Keyboard shortcuts

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