Documentation ¶
Index ¶
- Constants
- Variables
- func DecodePEM(data []byte) ([]byte, error)
- func EncodeCertPEM(certDER []byte) []byte
- func EncodeCertRequestPEM(crs []byte) []byte
- func EncodePrivateKeyPEM(privateKeyDER []byte) []byte
- func NewCertFromCA(caCert *x509.Certificate, caKey *rsa.PrivateKey, cfg Config) ([]byte, []byte, error)
- func NewCertFromCA2(ca, caKey []byte, cfg Config) ([]byte, []byte, error)
- func NewCertRequest(req Request) ([]byte, []byte, error)
- func NewSelfSignedCA(cfg Config) ([]byte, []byte, error)
- func ReadPEMFileAndDecode(filename string) ([]byte, error)
- func SaveCertKeyToFile(certDER []byte, keyDER []byte, certPath, keyPath string) error
- func SaveCertToFile(certDER []byte, certPath string) error
- func SaveFile(content []byte, filename string) error
- func SavePrivateKeyToFile(keyDER []byte, keyPath string) error
- func VerifyCert(caDER, certDER []byte, usages []x509.ExtKeyUsage) error
- type Config
- type Manager
- type Request
- type SignCertFunc
Constants ¶
View Source
const ( DefaultCountry = "CN" DefaultOrganization = "fabedge.io" DefaultCAName = "Fabedge CA" )
Variables ¶
View Source
var ( ExtKeyUsagesServerAndClient = []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth} ExtKeyUsagesServerOnly = []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth} ExtKeyUsagesClientOnly = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth} )
Functions ¶
func EncodeCertPEM ¶
func EncodeCertRequestPEM ¶
func EncodePrivateKeyPEM ¶
func NewCertFromCA ¶
func NewCertFromCA(caCert *x509.Certificate, caKey *rsa.PrivateKey, cfg Config) ([]byte, []byte, error)
NewCertFromCA creates certificate and key from specified CA cert/key pair
func NewCertFromCA2 ¶
NewCertFromCA2 creates certificate and key from specified CA cert/key pair
func NewSelfSignedCA ¶
NewSelfSignedCA create a CA cert/key pair
func ReadPEMFileAndDecode ¶
func SaveCertKeyToFile ¶
func SaveCertToFile ¶
func SavePrivateKeyToFile ¶
func VerifyCert ¶
func VerifyCert(caDER, certDER []byte, usages []x509.ExtKeyUsage) error
VerifyCert verifies the certificate by CA certificate
Types ¶
type Manager ¶
type Manager interface { // NewCertKey Create a cert/key pair from CA with specified config NewCertKey(cfg Config) (certDER []byte, keyDER []byte, err error) SignCert(csr []byte) ([]byte, error) VerifyCert(cert *x509.Certificate, usages []x509.ExtKeyUsage) error VerifyCertInPEM(certPEM []byte, usages []x509.ExtKeyUsage) error GetCACert() *x509.Certificate GetCACertPEM() []byte }
func NewRemoteManager ¶
func NewRemoteManager(caCertDER []byte, signCert SignCertFunc) (Manager, error)
type SignCertFunc ¶
SignCertFunc receive csr and return a cert bytes
Click to show internal directories.
Click to hide internal directories.