netutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 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

Overview

Package netutil provides race-free CA bundle loading, HTTP transport cloning, and bounded HTTP client construction without mutating http.DefaultTransport in place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneDefaultTransport

func CloneDefaultTransport() *http.Transport

CloneDefaultTransport clones Go's default transport and attaches TLSConfig if extra CAs are configured, without ever mutating http.DefaultTransport or sharing mutable *tls.Config pointers across callers.

func LoadCertPool

func LoadCertPool(caFile string) (*x509.CertPool, error)

LoadCertPool returns a copy of the system certificate pool augmented with the PEM-encoded certificates read from caFile.

func NewClient

func NewClient(timeout time.Duration) *http.Client

NewClient returns an HTTP client bounded by timeout using a cloned default transport (including any extra CAs configured via SetExtraCAs).

func NewTransport

func NewTransport(caFile string) (*http.Transport, error)

NewTransport clones Go's default transport and, when caFile is non-empty, configures RootCAs from LoadCertPool(caFile).

func ResetExtraCAs

func ResetExtraCAs()

ResetExtraCAs clears any extra certificate authorities configured via SetExtraCAs.

func SetExtraCAs

func SetExtraCAs(caFile string) error

SetExtraCAs loads PEM certificates from caFile on top of the system certificate pool for subsequent TLSConfig, CloneDefaultTransport, and NewClient calls. Passing "" clears any previously configured extra CAs. It never mutates http.DefaultTransport in place.

func TLSConfig

func TLSConfig() *tls.Config

TLSConfig returns a fresh TLS configuration trusting the extra CAs set via SetExtraCAs (with MinVersion TLS 1.2), or nil when none are configured.

Types

This section is empty.

Jump to

Keyboard shortcuts

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