tls

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ErrTLSHandshakeFailed greet.ErrorCode = "tls_handshake_failed"
	ErrTLSConfigFailed    greet.ErrorCode = "tls_config_failed"
)
View Source
const DefaultTLSPort = 443

DefaultTLSPort is the well-known port for TLS (HTTPS).

View Source
const ProtocolName = "tls"

ProtocolName is the registered name for the TLS protocol.

Variables

This section is empty.

Functions

func BuildTLSConfig added in v1.0.3

func BuildTLSConfig(cfg *TLSConfig, host string) (*tls.Config, error)

BuildTLSConfig constructs a crypto/tls.Config from the TLSConfig settings. When cfg is nil, the default (InsecureSkipVerify=true, ServerName=host) is used.

Types

type CertChainEntry

type CertChainEntry struct {
	Subject           string
	Issuer            string
	Serial            string
	NotBefore         string
	NotAfter          string
	Version           int
	DNSNames          []string
	IPAddresses       []string
	IsCA              bool
	SignatureAlgo     string
	PublicKeyAlgo     string
	SHA256Fingerprint string

	// Status holds Chrome-style CERT_ checks for this individual certificate.
	// ref: https://github.com/chromium/chromium/blob/main/net/cert/cert_status_flags.cc
	Status []string
}

CertChainEntry holds the details of a single certificate in the chain.

type TLS

type TLS struct{}

TLS implements a TLS connectivity and certificate probe as an AppLayer. It performs a TLS handshake over an already-dialed net.Conn, with InsecureSkipVerify, and reports Chrome-style CERT_ status checks.

func New added in v1.0.3

func New() *TLS

New creates a new TLS application layer.

func (*TLS) BaseTransport added in v1.0.3

func (t *TLS) BaseTransport() greet.Transport

func (*TLS) DefaultPort

func (t *TLS) DefaultPort() int

func (*TLS) Description

func (t *TLS) Description() string

func (*TLS) Handshake added in v1.0.3

func (t *TLS) Handshake(ctx context.Context, start time.Time, conn net.Conn, host string, port int, cfg *greet.GreetConfig) (net.Conn, greet.LayerData, greet.LayerTiming, error)

Handshake upgrades conn to TLS, performs the handshake, and returns the certificate chain with Chrome-style status checks. It returns the *tls.Conn so subsequent layers (e.g. http) can read/write over the encrypted channel.

func (*TLS) Name

func (t *TLS) Name() string

type TLSConfig added in v1.0.3

type TLSConfig struct {
	// ServerName overrides the SNI hostname sent in the ClientHello.
	// When empty, the target host is used.
	ServerName string

	// CertPEM is the PEM-encoded client certificate for mTLS.
	// When non-empty, the certificate is presented to the server
	// during the handshake. KeyPEM must also be set.
	CertPEM []byte

	// KeyPEM is the PEM-encoded private key for the client certificate.
	// When empty and CertPEM is non-empty, the key is expected to be
	// bundled in the same PEM block as CertPEM.
	KeyPEM []byte

	// CAPEM is the PEM-encoded CA certificate pool. When non-empty,
	// the pool is used as the root of trust (RootCAs) instead of
	// skipping verification entirely.
	CAPEM []byte

	// InsecureSkipVerify controls whether the server's certificate chain
	// and hostname are verified. Defaults to true.
	InsecureSkipVerify bool
}

TLSConfig holds per-layer configuration for the TLS layer. All PEM fields accept raw bytes (loaded from file, stream, embed, etc.).

func DefaultTLSConfig added in v1.0.3

func DefaultTLSConfig() *TLSConfig

DefaultTLSConfig returns a TLSConfig with safe defaults.

func (*TLSConfig) LayerConfigName added in v1.0.3

func (c *TLSConfig) LayerConfigName() string

type TLSResult

type TLSResult struct {
	// CertChain contains all presented certificates sorted from leaf to root.
	// The leaf certificate is always CertChain[0].
	CertChain []CertChainEntry

	// Status is the final concluded chain status. It holds the statuses from
	// the first certificate (walking leaf→root) that has a non-OK check, or
	// ["OK"] if every certificate in the chain passes all checks.
	Status []string
}

TLSResult holds the full certificate chain and the concluded chain status from a TLS handshake.

func (*TLSResult) LayerDataName added in v1.0.3

func (r *TLSResult) LayerDataName() string

Jump to

Keyboard shortcuts

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