Documentation ¶
Index ¶
- Constants
- func CreateCertPool(certs ...*x509.Certificate) *x509.CertPool
- func CreateClientTLSCredentials(args ClientTLSConfigArgs[[]byte]) (cred credentials.TransportCredentials, err error)
- func CreateServerTLSConfig(args ServerTLSConfigArgs[[]byte]) (cred credentials.TransportCredentials, err error)
- func CreateTLSConfig(cert CertKey, roots *x509.CertPool) *tls.Config
- func EncodeCertificateToPEM(cert *x509.Certificate) (certPEMBytes []byte, err error)
- func EncodePrivateKeyToPEM(key *rsa.PrivateKey) (keyPEMBytes []byte, err error)
- func EncodePublicKeyToPEM(key *rsa.PublicKey) (keyPEMBytes []byte, err error)
- func EncodeRSAPrivateKeyToPEM(key *rsa.PrivateKey) (keyPEMBytes []byte, err error)
- func EncodeRSAPublicKeyToPEM(key *rsa.PublicKey) (keyPEMBytes []byte, err error)
- func LoadClientTLSCredentials(args ClientTLSConfigArgs[string]) (cred credentials.TransportCredentials, err error)
- func LoadServerTLSCredentials(args ServerTLSConfigArgs[string]) (cred credentials.TransportCredentials, err error)
- func ParseCertificateFromFile(path string) (cert *x509.Certificate, err error)
- func ParseCertificateFromPEM(certPEMBytes []byte) (cert *x509.Certificate, err error)
- func ParsePrivateKeyFromFile(path string) (key *rsa.PrivateKey, err error)
- func ParsePrivateKeyFromPEM(keyPEMBytes []byte) (key *rsa.PrivateKey, err error)
- func VerifyCertificate(args VerifyCertificateArgs) (err error)
- type CertKey
- func GenerateBasicCA(commonName string, organization string, country string, duration time.Duration) (CertKey, error)
- func GenerateBasicClientCert(commonName string, issuer CertKey, duration time.Duration) (CertKey, error)
- func GenerateBasicIntermediateCA(commonName string, organization string, country string, issuer CertKey, ...) (CertKey, error)
- func GenerateBasicServerCert(commonName string, dnsNames []string, issuer CertKey, duration time.Duration) (CertKey, error)
- func GenerateCertificate(certType CertificateType, args CertificateArgs) (res CertKey, err error)
- type CertificateArgs
- type CertificateType
- type ClientTLSConfigArgs
- type ServerTLSConfigArgs
- type VerifyCertificateArgs
Constants ¶
View Source
const DefaultKeySize = 2048
View Source
const MinKeySize = 2048
Variables ¶
This section is empty.
Functions ¶
func CreateCertPool ¶
func CreateCertPool(certs ...*x509.Certificate) *x509.CertPool
CreateCertPool creates a new certificate pool from the given certificates
func CreateClientTLSCredentials ¶
func CreateClientTLSCredentials(args ClientTLSConfigArgs[[]byte]) (cred credentials.TransportCredentials, err error)
func CreateServerTLSConfig ¶
func CreateServerTLSConfig(args ServerTLSConfigArgs[[]byte]) (cred credentials.TransportCredentials, err error)
func CreateTLSConfig ¶
CreateTLSConfig creates a basic TLS config for server or client
func EncodeCertificateToPEM ¶
func EncodeCertificateToPEM(cert *x509.Certificate) (certPEMBytes []byte, err error)
func EncodePrivateKeyToPEM ¶
func EncodePrivateKeyToPEM(key *rsa.PrivateKey) (keyPEMBytes []byte, err error)
func EncodePublicKeyToPEM ¶
func EncodeRSAPrivateKeyToPEM ¶
func EncodeRSAPrivateKeyToPEM(key *rsa.PrivateKey) (keyPEMBytes []byte, err error)
func EncodeRSAPublicKeyToPEM ¶
func LoadClientTLSCredentials ¶
func LoadClientTLSCredentials(args ClientTLSConfigArgs[string]) (cred credentials.TransportCredentials, err error)
func LoadServerTLSCredentials ¶
func LoadServerTLSCredentials(args ServerTLSConfigArgs[string]) (cred credentials.TransportCredentials, err error)
func ParseCertificateFromFile ¶
func ParseCertificateFromFile(path string) (cert *x509.Certificate, err error)
func ParseCertificateFromPEM ¶
func ParseCertificateFromPEM(certPEMBytes []byte) (cert *x509.Certificate, err error)
func ParsePrivateKeyFromFile ¶
func ParsePrivateKeyFromFile(path string) (key *rsa.PrivateKey, err error)
func ParsePrivateKeyFromPEM ¶
func ParsePrivateKeyFromPEM(keyPEMBytes []byte) (key *rsa.PrivateKey, err error)
func VerifyCertificate ¶
func VerifyCertificate(args VerifyCertificateArgs) (err error)
Types ¶
type CertKey ¶
type CertKey struct { Cert *x509.Certificate Key *rsa.PrivateKey }
func GenerateBasicCA ¶
func GenerateBasicCA(commonName string, organization string, country string, duration time.Duration) (CertKey, error)
GenerateBasicCA creates a root CA with basic settings
func GenerateBasicClientCert ¶
func GenerateBasicClientCert(commonName string, issuer CertKey, duration time.Duration) (CertKey, error)
GenerateBasicClientCert creates a client certificate with basic settings
func GenerateBasicIntermediateCA ¶
func GenerateBasicIntermediateCA(commonName string, organization string, country string, issuer CertKey, duration time.Duration) (CertKey, error)
GenerateBasicIntermediateCA creates an intermediate CA with basic settings
func GenerateBasicServerCert ¶
func GenerateBasicServerCert(commonName string, dnsNames []string, issuer CertKey, duration time.Duration) (CertKey, error)
GenerateBasicServerCert creates a server certificate with basic settings
func GenerateCertificate ¶
func GenerateCertificate(certType CertificateType, args CertificateArgs) (res CertKey, err error)
func (*CertKey) TLSCertificate ¶
func (c *CertKey) TLSCertificate() *tls.Certificate
type CertificateArgs ¶
type CertificateType ¶
type CertificateType int
const ( CertificateTypeRootCA CertificateType = iota CertificateTypeIntermediateCA CertificateTypeServer CertificateTypeClient )
type ClientTLSConfigArgs ¶
type ServerTLSConfigArgs ¶
type ServerTLSConfigArgs[T any] struct { Cert T Key T CA T }
type VerifyCertificateArgs ¶
type VerifyCertificateArgs struct { Type CertificateType Cert *x509.Certificate DNSName string Intermediates []*x509.Certificate Roots []*x509.Certificate }
Click to show internal directories.
Click to hide internal directories.