certificate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(files ...string) bool

only all files exist return true, other return false

func Expired

func Expired(certPath string, pool *x509.CertPool, days int) bool

less than {days} days will be treat as exired

func GenerateCertKey

func GenerateCertKey(regen bool, commonName string, organization []string, altNames *certutil.AltNames, extKeyUsage []x509.ExtKeyUsage, caCertPath, caKeyPath, certPath, keyPath string) (bool, error)

set regen=true to force gen new cert, CA certificate will be written as second certificate in $certPath

func GenerateClientCertKey

func GenerateClientCertKey(regen bool, commonName string, organization []string, caCertPath, caKeyPath, certPath, keyPath string) (bool, error)

set regen=true to force gen new cert, CA certificate will be written as second certificate in $certPath

func GenerateRSAKeyPair

func GenerateRSAKeyPair(regen bool, keyFie string) (bool, error)

func GenerateServerCertKey

func GenerateServerCertKey(regen bool, commonName string, organization []string, altNames *certutil.AltNames, caCertPath, caKeyPath, certPath, keyPath string) (bool, error)

set regen=true to force gen new cert, CA certificate will be written as second certificate in $certPath

func GenerateSigningCertKey

func GenerateSigningCertKey(regen bool, prefix, certFile, keyFile string) (bool, error)

write signing Certkey with `CN: {prefix}-ca@{time.Now().Unix()}` to certFile if keyFile valid, it will be use, or generate. if generate new ,then return (true,nil); or return (false,nil)

func LoadCertPool

func LoadCertPool(caCertPath string) (*x509.CertPool, error)

func LoadCertificate

func LoadCertificate(certPath string) (*x509.Certificate, error)

func LoadCertificateAsBase64

func LoadCertificateAsBase64(certPath string) (string, error)

func LoadCertificates

func LoadCertificates(certPath string) ([]*x509.Certificate, error)

if client/server certificate generate by this package, return[0] is client/server certificate, return[1] is CA certificate

func LoadFileAsBase64

func LoadFileAsBase64(filePath string) (string, error)

func NotExists

func NotExists(files ...string) bool

func ValidateCA

func ValidateCA(certPath string, caCertPath string) bool

validate if cert is valid to this ca

func ValidateExpired

func ValidateExpired(certPath string, caCertPath string, days int) bool

less than {days} days will be treat as exired

func ValidateIssuer

func ValidateIssuer(child *x509.Certificate, issuer *x509.Certificate) bool

verifies that the signature on cert is a valid signature from issuer.

func ValidateRSAKeyFile

func ValidateRSAKeyFile(keyFie string) bool

func ValidateTLSPair

func ValidateTLSPair(certPath string, keyPath string) bool

check if certificate and key are one pair

Types

This section is empty.

Jump to

Keyboard shortcuts

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