Documentation
¶
Overview ¶
Package tlsutil provides the TLS certificate for nerdui's HTTPS server (ADR-0005): either a generated self-signed certificate kept in <data-dir>/tls, or a user-provided certificate/key pair that is reloaded when the files change.
Index ¶
Constants ¶
const ( // SelfSignedValidity is the lifetime of generated certificates (Apple platforms reject // longer-lived TLS server certificates). SelfSignedValidity = 825 * 24 * time.Hour // RenewBefore is how long before expiry a self-signed certificate is regenerated. RenewBefore = 30 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func Fingerprint ¶
func Fingerprint(cert *x509.Certificate) string
Fingerprint returns the colon-separated upper-case SHA-256 fingerprint of a certificate.
func LocalHosts ¶
func LocalHosts() []string
LocalHosts returns SANs for a self-signed certificate: "localhost", the hostname and all non-link-local unicast addresses of the machine.
func SelfSignedCertFile ¶
SelfSignedCertFile returns the path of the self-signed certificate kept in dir.
Types ¶
type Info ¶
type Info struct {
SelfSigned bool
CertFile string
NotAfter time.Time
DNSNames []string
IPAddresses []net.IP
// SHA256 is the colon-separated SHA-256 fingerprint as shown by browsers.
SHA256 string
}
Info describes the certificate currently served.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager serves a certificate via tls.Config.GetCertificate and renews/reloads it.
func FromFiles ¶
FromFiles returns a manager for a user-provided certificate and key (PEM). The files are re-read when their modification time changes, e.g. after certbot renews them.
func SelfSigned ¶
SelfSigned returns a manager for a self-signed certificate stored in dir (created 0700). The certificate is generated on first use and regenerated when it is invalid or expires within RenewBefore. hosts become the SANs (DNS names or IP addresses).