Documentation ¶
Index ¶
- Variables
- func GetConfig(certPEM, keyPEM []byte) (*tls.Config, error)
- func NewTLSTemplate() (*x509.Certificate, error)
- type Installer
- func (installer *Installer) InstallCert(certPEM []byte) error
- func (installer *Installer) IsCertInstalled(certPEM []byte) bool
- func (installer *Installer) LogCertInstallStatus(certPEM []byte)
- func (installer *Installer) OSSupportCertInstall() bool
- func (installer *Installer) UninstallCert(certPEM []byte) error
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 (
ErrUserCanceledCertificateInstall = errors.New("the user cancelled the authorization dialog")
)
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 {
// contains filtered or unexported fields
}
func NewInstaller ¶
func NewInstaller() *Installer
func (*Installer) InstallCert ¶
func (*Installer) IsCertInstalled ¶ added in v3.6.0
func (*Installer) LogCertInstallStatus ¶ added in v3.7.1
LogCertInstallStatus reports the current status of the certificate installation in the log. If certificate installation is not supported on the platform, this function does nothing.
func (*Installer) OSSupportCertInstall ¶ added in v3.7.1
func (*Installer) UninstallCert ¶
Click to show internal directories.
Click to hide internal directories.