tlsutil

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tlsutil handles low-level X.509 certificates: generating the self-signed cert used as the internal pre-ACME fallback, reading certificate metadata for display, computing SHA-256 pins, and writing key pairs to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertPinSHA256

func CertPinSHA256(path string) (string, error)

CertPinSHA256 returns the hex-encoded SHA-256 of the leaf certificate's DER bytes at path. Clients pin this via pinnedPeerCertSha256 to trust a specific (e.g. self-signed) cert without CA verification — the modern replacement for allowInsecure, and stricter (only this exact cert is accepted). Xray expects lowercase hex (NOT base64), matching `openssl x509 -fingerprint -sha256`.

func GenerateSelfSigned

func GenerateSelfSigned(host string) (certPEM, keyPEM []byte, err error)

GenerateSelfSigned creates a self-signed certificate for host (an IP address or a DNS name), valid ~1 year, returning PEM cert+key. It's a fallback so the panel can still serve TLS when ACME is unavailable (e.g. rate-limited); the renew loop replaces it with a real cert once ACME succeeds.

func WriteKeyPair

func WriteKeyPair(certPath, keyPath string, certPEM, keyPEM []byte) error

WriteKeyPair writes cert and key PEM to the given paths (0600 key). Both files are staged to <path>.new first, then renamed back-to-back, so the window in which a concurrent reader (e.g. an Xray reload) could see a new cert beside an old key shrinks to the gap between two rename syscalls instead of spanning a whole file write. (Truly atomic cross-file replacement isn't possible.)

Types

type CertInfo

type CertInfo struct {
	Subject   string    `json:"subject"`
	Issuer    string    `json:"issuer"`
	NotBefore time.Time `json:"not_before"`
	NotAfter  time.Time `json:"not_after"`
	DaysLeft  int       `json:"days_left"`
}

CertInfo is summary metadata about a certificate on disk.

func ReadCertInfo

func ReadCertInfo(path string) (*CertInfo, error)

ReadCertInfo parses the leaf certificate at path for display.

Jump to

Keyboard shortcuts

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