MCPcopy Index your code
hub / github.com/PasarGuard/node / LoadClientPool

Function LoadClientPool

pkg/tlsutil/tls.go:25–40  ·  view source on GitHub ↗
(cert string)

Source from the content-addressed store, hash-verified

23}
24
25func LoadClientPool(cert string) (*x509.CertPool, error) {
26 pemServerCA, err := os.ReadFile(cert)
27 if err != nil {
28 return nil, fmt.Errorf("failed to read server certificate: %v", err)
29 }
30
31 certPool, err := x509.SystemCertPool()
32 if err != nil {
33 certPool = x509.NewCertPool()
34 }
35 if !certPool.AppendCertsFromPEM(pemServerCA) {
36 return nil, fmt.Errorf("failed to add server CA's certificate")
37 }
38
39 return certPool, nil
40}
41
42func CreateHTTPClient(certPool *x509.CertPool, hostname string) *http.Client {
43 tlsConfig := &tls.Config{RootCAs: certPool, ServerName: hostname}

Callers 2

TestMainFunction · 0.92
TestMainFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestMainFunction · 0.74
TestMainFunction · 0.74