tlsconfig

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package tlsconfig provides shared TLS configuration for HTTP clients.

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout is the default timeout for HTTP clients.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(cfg Config) (*http.Client, error)

NewHTTPClient creates an http.Client with the specified TLS configuration and the default timeout of 30 seconds.

func NewHTTPClientWithTimeout

func NewHTTPClientWithTimeout(cfg Config, timeout time.Duration) (*http.Client, error)

NewHTTPClientWithTimeout creates an http.Client with the specified TLS configuration and timeout.

Types

type Config

type Config struct {
	// Insecure disables TLS certificate verification.
	// NOT RECOMMENDED FOR PRODUCTION USE.
	Insecure bool

	// CACertFile is path to a PEM file containing trusted CA certificates.
	// If empty, system CA certificates are used.
	CACertFile string
}

Config holds TLS configuration options for HTTP clients.

func (Config) ValidateURL

func (c Config) ValidateURL(url string) error

ValidateURL checks if a URL is allowed given this TLS configuration. Returns an error if the URL uses http:// without insecure mode enabled.

Jump to

Keyboard shortcuts

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