certifi

package module
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCertPool

func NewCertPool() *x509.CertPool
Example (Http)
package main

import (
	"crypto/tls"
	"fmt"
	"io"
	"net/http"

	"github.com/buglloc/certifi"
)

func main() {
	httpc := http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{
				RootCAs: certifi.NewCertPool(),
			},
		},
	}

	resp, err := httpc.Get("https://google.com/")
	if err != nil {
		panic(fmt.Sprintf("http failed: %v\n", err))
	}

	_, _ = io.Copy(io.Discard, resp.Body)
	_ = resp.Body.Close()

	fmt.Printf("successful, status code: %d\n", resp.StatusCode)
}
Output:

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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