Documentation
¶
Index ¶
- Constants
- Variables
- func CheckCertIsExist(certPath, keyPath, commonName string, caType int) ([]byte, []byte, error)
- func ClientGenerateCertificate(host, name string, port int, clientType int) (*mtls.ClientConfig, error)
- func ClientGetCertificate(operator string) ([]byte, []byte, error)
- func ClientListCertificates() []*x509.Certificate
- func ClientRemoveCertificate(operator string) error
- func GenerateCertificateAuthority(caType int, commonName string) (*x509.Certificate, *rsa.PrivateKey)
- func GenerateECCCertificate(caType int, commonName string, isCA bool, isClient bool) ([]byte, []byte)
- func GenerateListenerCertificate(config *configs.TlsConfig) ([]byte, []byte, error)
- func GenerateRSACertificate(caType int, commonName string, isCA bool, isClient bool, subject *pkix.Name) ([]byte, []byte)
- func GetACMEDir() string
- func GetACMEManager(domain string) *autocert.Manager
- func GetCertificate(caType int, keyType string, commonName string) ([]byte, []byte, error)
- func GetCertificateAuthority() (*x509.Certificate, *rsa.PrivateKey, error)
- func GetCertificateAuthorityPEM(caCertPath, caKeyPath string) ([]byte, []byte, error)
- func GetECCCertificate(caType int, commonName string) ([]byte, []byte, error)
- func GetOperatorServerMTLSConfig(host string) *tls.Config
- func GetRSACertificate(caType int, commonName string) ([]byte, []byte, error)
- func ParseCertificateAuthority(certPEM, keyPEM []byte) (*x509.Certificate, *rsa.PrivateKey, error)
- func RemoveCertificate(caType int, keyType string, commonName string) error
- func RsaKeySize() int
- func SaveCertificateAuthority(caType int, cert []byte, key []byte)
- func SaveToPEMFile(filename string, pemData []byte) error
- func ServerGenerateCertificate(name string, isCA bool, cfgPath string) ([]byte, []byte, error)
- func ServerGetCertificate(hostname string) ([]byte, []byte, error)
Constants ¶
const ( // ECCKey - Namespace for ECC keys ECCKey = "ecc" // RSAKey - Namespace for RSA keys RSAKey = "rsa" RootName = "Root" OperatorName = "server.operator" ListenerName = "default" )
const ( OperatorCA = iota + 1 ListenerCA ImplantCA RootCA )
const (
// ACMEDirName - Name of dir to store ACME certs
ACMEDirName = "acme"
)
const (
ListenerNamespace = "listener" // Listener servers
)
Variables ¶
var ( // ErrCertDoesNotExist - Returned if a GetCertificate() is called for a cert/cn that does not exist ErrCertDoesNotExist = errors.New("certificate does not exist") )
var (
// TLSKeyLogger - File descriptor for logging TLS keys
TLSKeyLogger = newKeyLogger()
)
Functions ¶
func CheckCertIsExist ¶
func ClientGenerateCertificate ¶
func ClientGenerateCertificate(host, name string, port int, clientType int) (*mtls.ClientConfig, error)
ClientGenerateCertificate - Generate a certificate signed with a given CA
func ClientGetCertificate ¶
ClientGetCertificate - Helper function to fetch a client cert
func ClientListCertificates ¶
func ClientListCertificates() []*x509.Certificate
ClientListCertificates - Get all client certificates
func ClientRemoveCertificate ¶
ClientRemoveCertificate - Helper function to remove a client cert
func GenerateCertificateAuthority ¶
func GenerateCertificateAuthority(caType int, commonName string) (*x509.Certificate, *rsa.PrivateKey)
GenerateCertificateAuthority - Creates a new CA cert for a given type
func GenerateECCCertificate ¶
func GenerateECCCertificate(caType int, commonName string, isCA bool, isClient bool) ([]byte, []byte)
GenerateECCCertificate - Generate a TLS certificate with the given parameters We choose some reasonable defaults like Curve, Key Size, ValidFor, etc. Returns two strings `cert` and `key` (PEM Encoded).
func GenerateRSACertificate ¶
func GenerateRSACertificate(caType int, commonName string, isCA bool, isClient bool, subject *pkix.Name) ([]byte, []byte)
GenerateRSACertificate - Generates an RSA Certificate
func GetACMEManager ¶
GetACMEManager - Get an ACME cert/tls config with the certs
func GetCertificate ¶
GetCertificate - Get the PEM encoded certificate & key for a host
func GetCertificateAuthority ¶
func GetCertificateAuthority() (*x509.Certificate, *rsa.PrivateKey, error)
GetCertificateAuthority - Get the current CA certificate
func GetCertificateAuthorityPEM ¶
GetCertificateAuthorityPEM - Get PEM encoded CA cert/key
func GetECCCertificate ¶
GetECCCertificate - Get an ECC certificate
func GetOperatorServerMTLSConfig ¶
GetOperatorServerMTLSConfig - Get the TLS config for the operator server
func GetRSACertificate ¶
GetRSACertificate - Get an RSA certificate
func ParseCertificateAuthority ¶
func ParseCertificateAuthority(certPEM, keyPEM []byte) (*x509.Certificate, *rsa.PrivateKey, error)
func RemoveCertificate ¶
RemoveCertificate - Remove a certificate from the cert store
func RsaKeySize ¶
func RsaKeySize() int
func SaveCertificateAuthority ¶
SaveCertificateAuthority - Save the certificate and the key to the filesystem doesn't return an error because errors are fatal. If we can't generate CAs, then we can't secure communication and we should die a horrible death.
func SaveToPEMFile ¶
SaveToPEMFile 将 PEM 格式数据保存到文件
func ServerGenerateCertificate ¶
ServerGenerateCertificate - Generate a certificate signed with a given CA
Types ¶
This section is empty.