Documentation
¶
Overview ¶
Package tlstester provides the core orchestration engine and programmatic APIs for probing network targets, inspecting X.509 certificate chains, scanning supported TLS protocols/ciphers, querying active AIA OCSP responders, and verifying application HTTP health.
OBJECTIVES: Supply a thread-safe, side-effect-free diagnostic engine that can be consumed both as an importable Go library package and as a command-line binary.
CORE COMPONENTS & DATA FLOW: - Config (config.go): Holds diagnostic parameters, flags, timeouts, and options. - Target & TargetResult (target.go): Defines target structures, Cartesian grid expansion, and diagnostic output models. - Runner (runner.go): Coordinates Goroutine worker pools, TLS config creation, and probe dispatches. - Security Environment (diagnose.go): Inspects Go compiler runtime and cryptographic environment.
Package tlstester security environment diagnostic inspector (-diagnose flag).
OBJECTIVES: Provide runtime inspection of local Go compiler versions, operating system architecture, supported TLS protocol ranges, elliptic curve groups, supported cipher suites, and system trust pool status.
CORE COMPONENTS & DATA FLOW: - SecurityEnvironment (diagnose.go): Struct capturing Go crypto environment metadata. - GetSecurityEnvironment (diagnose.go): Populates SecurityEnvironment properties. - DumpDiagnostics (diagnose.go): Formats and writes diagnostic tables to an io.Writer.
Package tlstester runner orchestration engine and TLS configuration builder.
OBJECTIVES: Provide thread-safe Goroutine worker pool execution (`RunDiagnostics`) to process diagnostic targets concurrently with context deadlines, clean channel synchronization, result order preservation, and zero state mutations.
CORE COMPONENTS & DATA FLOW:
- CreateTLSConfig (runner.go): Initializes a tls.Config with requested TLS versions, cipher suites, SNI options, custom truststores, and mTLS client certificates.
- RunDiagnostics (runner.go): Orchestrates parallel task dispatch across worker Goroutines with indexed channels to preserve input order in output results.
- ExecuteTarget (runner.go): Executes sequential diagnostic steps (TCP socket, TLS handshake, HTTP probe, OCSP check, protocol sweep) for a single target tuple, extracting leaf certificate metadata (subject, issuer, SANs, expiration, key type/size) for library consumers.
- getKeyInfo (runner.go): Extracts public key type (RSA, ECDSA, Ed25519) and bit size from certificates.
CONCURRENCY MODEL:
- Worker pool size bounded by min(cfg.Workers, len(targets)).
- Channel buffer sizes bounded by maxChannelBuffer (10000) to prevent OOM on large target lists.
- Indexed result collection preserves input target order regardless of completion sequence.
Package tlstester target data structures and multi-source target parser.
OBJECTIVES: Provide parsing and validation of target endpoints from host:port strings, URLs, list input files/STDIN, and Cartesian hostname/port combinations.
CORE COMPONENTS & DATA FLOW:
- Target (target.go): Struct representing a single host, port, and HTTP path target tuple.
- TargetResult (target.go): Comprehensive diagnostic output data structure compiling DNS, TCP, TLS, X.509 cert, HTTP ALPN, active OCSP, and protocol scan results.
- ParseURLTarget & ParseTargets (target.go): Deduplicates and expands input target sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTLSConfig ¶
CreateTLSConfig initializes a tls.Config based on Config parameters and target properties. Configures TLS min/max versions, cipher suites, SNI overrides, root truststores, and mTLS client keypairs.
func DumpDiagnostics ¶
DumpDiagnostics formats and writes Go security environment properties and cipher suite lists to an io.Writer. Returns an error if writing to the output stream encounters an I/O error.
Types ¶
type Config ¶
type Config struct {
Hostport string `json:"hostport,omitempty"`
Endpoints []string `json:"endpoints,omitempty"`
URLs []string `json:"urls,omitempty"`
File string `json:"file,omitempty"`
Hostnames string `json:"hostnames,omitempty"`
Ports string `json:"ports,omitempty"`
Workers int `json:"workers"`
Timeout time.Duration `json:"timeout_ns"`
Retries int `json:"retries"`
TLSVersion string `json:"tls_version,omitempty"`
CipherSuite string `json:"cipher_suite,omitempty"`
Keystore string `json:"keystore,omitempty"`
Truststore string `json:"truststore,omitempty"`
InsecureSkipVerify bool `json:"insecure_skip_verify"`
SNI string `json:"sni,omitempty"`
NoSNI bool `json:"no_sni"`
Proxy string `json:"proxy,omitempty"`
ProxyType string `json:"proxy_type,omitempty"`
Headers []string `json:"headers,omitempty"`
AssertStatus string `json:"assert_status,omitempty"`
Cert bool `json:"cert"`
ExportCert string `json:"export_cert,omitempty"`
Scan bool `json:"scan"`
JSON bool `json:"json"`
CSV string `json:"csv,omitempty"`
Log string `json:"log,omitempty"`
Color bool `json:"color"`
NoColor bool `json:"no_color"`
Verbose bool `json:"verbose"`
Diagnose bool `json:"diagnose"`
Version bool `json:"version"`
WarnDays int `json:"warn_days"`
CheckOCSP bool `json:"check_ocsp"`
StrictParsing bool `json:"strict_parsing"`
}
Config holds configuration parameters and execution options for TLS diagnostic operations. It is side-effect-free and thread-safe for concurrent read access across worker Goroutines.
type ParseResult ¶
ParseResult contains parsed targets and any parse warnings encountered.
func ParseTargetsWithWarnings ¶
func ParseTargetsWithWarnings(cfg *Config) (*ParseResult, error)
ParseTargetsWithWarnings is like ParseTargets but also returns parse warnings.
type SecurityEnvironment ¶
type SecurityEnvironment struct {
CompilerVersion string `json:"compiler_version"`
OS string `json:"os"`
Arch string `json:"arch"`
SupportedTLS []string `json:"supported_tls"`
SupportedCurves []string `json:"supported_curves"`
SystemPoolLoaded bool `json:"system_pool_loaded"`
}
SecurityEnvironment holds details about local Go runtime crypto properties and capabilities.
func GetSecurityEnvironment ¶
func GetSecurityEnvironment() SecurityEnvironment
GetSecurityEnvironment retrieves system crypto provider configuration and system trust pool status.
type StringSliceFlag ¶
type StringSliceFlag []string
StringSliceFlag assists CLI flag parsing for repeated slice flags (e.g. -endpoint, -url, -header).
func (*StringSliceFlag) Set ¶
func (s *StringSliceFlag) Set(value string) error
Set appends a newly parsed flag value to the StringSliceFlag slice.
func (*StringSliceFlag) String ¶
func (s *StringSliceFlag) String() string
String formats the slice as a comma-separated string for flag display.
type Target ¶
type Target struct {
Host string `json:"host"`
Port int `json:"port"`
HTTPPath string `json:"http_path,omitempty"`
RawTarget string `json:"raw_target"`
}
Target represents a single diagnostic target host, port, and optional HTTP path.
func ParseTargets ¶
ParseTargets compiles and deduplicates Target endpoints from all CLI inputs: - Hostport string (-hostport) - Repeated endpoints (-endpoint) - Repeated URLs (-url) - Target list files or STDIN (-file) - Cartesian grid expansion of hostnames (-hostname) across ports (-port)
Parse errors in target files are collected as warnings unless StrictParsing is enabled.
func ParseURLTarget ¶
ParseURLTarget parses a raw URL or endpoint string into a Target struct. Sanitizes whitespace, supplies default scheme `https://` if missing, and assigns default port 443.
type TargetResult ¶
type TargetResult struct {
Target Target `json:"target"`
ResolvedIPs []string `json:"resolved_ips"`
DNSLatency time.Duration `json:"dns_latency_ns"`
TCPLatency time.Duration `json:"tcp_latency_ns"`
TCPConnected bool `json:"tcp_connected"`
TLSHandshakeSuccess bool `json:"tls_handshake_success"`
TLSHandshakeLatency time.Duration `json:"tls_handshake_latency_ns"`
TLSProtocol string `json:"tls_protocol,omitempty"`
TLSCipher string `json:"tls_cipher,omitempty"`
TLSAlpn string `json:"tls_alpn,omitempty"`
NegotiatedGroup string `json:"negotiated_group,omitempty"`
OCSPStapled bool `json:"ocsp_stapled"`
SCTsPresent bool `json:"scts_present"`
SCTCount int `json:"sct_count"`
SCTs []probes.SCTInfo `json:"scts,omitempty"`
CertChainTrusted bool `json:"cert_chain_trusted"`
CertChainTrustError string `json:"cert_chain_trust_error,omitempty"`
CertExpirationWarning string `json:"cert_expiration_warning,omitempty"`
ActiveOCSPStatus string `json:"active_ocsp_status,omitempty"`
OCSPRevocation *probes.OCSPResult `json:"ocsp_revocation,omitempty"`
CapturedChain []*x509.Certificate `json:"-"`
// Leaf certificate info (extracted from CapturedChain[0] for convenience)
LeafSubject string `json:"leaf_subject,omitempty"`
LeafIssuer string `json:"leaf_issuer,omitempty"`
LeafSANs []string `json:"leaf_sans,omitempty"`
LeafNotBefore time.Time `json:"leaf_not_before,omitempty"`
LeafNotAfter time.Time `json:"leaf_not_after,omitempty"`
LeafIsExpired bool `json:"leaf_is_expired"`
LeafDaysRemaining int `json:"leaf_days_remaining"`
LeafSerial string `json:"leaf_serial,omitempty"`
LeafSignatureAlgorithm string `json:"leaf_signature_algorithm,omitempty"`
LeafKeyType string `json:"leaf_key_type,omitempty"`
LeafKeySize int `json:"leaf_key_size,omitempty"`
HTTPStatusLine string `json:"http_status_line,omitempty"`
HTTPAltSvcLine string `json:"http_alt_svc_line,omitempty"`
HTTPLatency time.Duration `json:"http_latency_ns,omitempty"`
ProtocolScanResults []probes.ProtocolScanResult `json:"protocol_scan_results,omitempty"`
ServerCiphers []string `json:"server_ciphers,omitempty"`
SessionResumptionAttempted bool `json:"session_resumption_attempted"`
SessionResumptionSuccess bool `json:"session_resumption_success"`
SessionResumptionLatency time.Duration `json:"session_resumption_latency_ns"`
QUICReachable bool `json:"quic_reachable"`
Error string `json:"error,omitempty"`
}
TargetResult aggregates complete diagnostic probe findings for a Target instance.
func ExecuteTarget ¶
func ExecuteTarget(ctx context.Context, cfg *Config, target Target) TargetResult
ExecuteTarget executes the complete sequence of granular diagnostic probes against a single target: 1. TCP socket dialing & proxy tunnel handshake. 2. TLS handshake, cipher/protocol negotiation, cert chain extraction. 3. Certificate expiration threshold calculation & active AIA OCSP query. 4. HTTP application probe with status assertion & Alt-Svc header extraction. 5. Capability scan across supported TLS versions, session ticket resumption, & QUIC datagram reachability.
func RunDiagnostics ¶
func RunDiagnostics(ctx context.Context, cfg *Config, targets []Target) []TargetResult
RunDiagnostics orchestrates parallel target probing using a context-aware Goroutine worker pool. Returns a consolidated slice of TargetResult objects in the same order as input targets.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package certs provides certificate handling, PEM truststore loading, mTLS client keypair loading, and certificate expiration calculations.
|
Package certs provides certificate handling, PEM truststore loading, mTLS client keypair loading, and certificate expiration calculations. |
|
cmd
|
|
|
tlstester
command
Package main provides the standalone executable binary entry point for tlstester.
|
Package main provides the standalone executable binary entry point for tlstester. |
|
Package probes low-level HTTP/ALPN application prober.
|
Package probes low-level HTTP/ALPN application prober. |
|
Package reporter provides side-effect-free diagnostic output formatting for stdout, files, or custom io.Writer targets.
|
Package reporter provides side-effect-free diagnostic output formatting for stdout, files, or custom io.Writer targets. |