Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTLSCertExpiresSoon = fmt.Errorf("TLS certificate will expire soon")
ErrTLSCertExpiresSoon is returned when the TLS certificate is about to expire.
View Source
var GenerateCert = func(template *x509.Certificate) ([]byte, []byte, error) { priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { return nil, nil, errors.Wrap(err, "failed to generate private key") } derBytes, err := x509.CreateCertificate(rand.Reader, template, template, &priv.PublicKey, priv) if err != nil { return nil, nil, errors.Wrap(err, "failed to create certificate") } certPEM := new(bytes.Buffer) if err := pem.Encode(certPEM, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil { return nil, nil, err } keyPEM := new(bytes.Buffer) if err := pem.Encode(keyPEM, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}); err != nil { return nil, nil, err } return certPEM.Bytes(), keyPEM.Bytes(), nil }
GenerateCert generates a new TLS certificate and returns it as PEM.
Functions ¶
func NewTLSTemplate ¶
func NewTLSTemplate() (*x509.Certificate, error)
NewTLSTemplate creates a new TLS template certificate with a random serial number.
Types ¶
type Installer ¶
type Installer struct{}
func NewInstaller ¶
func NewInstaller() *Installer
func (*Installer) InstallCert ¶
func (*Installer) UninstallCert ¶
Click to show internal directories.
Click to hide internal directories.