certificate

package
v0.0.0-...-eb2fa4d Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(network, ip, port string, timeout time.Duration, servername string) ([]x509.Certificate, error)

Get the certificate from network://ip:port without verification.

Servername is used for SNI.

func Verify

func Verify(certs []x509.Certificate, servername string) error

Verify the certificate chain.

Types

type Additional

type Additional struct {
	CommonName         string
	Hash               [32]byte
	NotAfter           time.Time
	Issuer             string
	PublicKey          PubKey
	SignatureAlgorithm x509.SignatureAlgorithm
}

Additional is the additional certificates (eg.: intermediate cert)

type Cert

type Cert struct {
	CommonName         string
	Hash               [32]byte // SHA256
	AlternativeNames   []string
	SignatureAlgorithm x509.SignatureAlgorithm
	PublicKey          PubKey
	SerialNumber       *big.Int
	Issuer             string
	NotBefore          time.Time
	NotAfter           time.Time
	Verified           bool
	VerifiedError      error // This is set if Verified == false
	Chain              []Additional
}

Cert is hold the fields "interesting" part of the certficate chain.

func Scan

func Scan(network, ip, port string, timeout time.Duration, servername string) (Cert, error)

Scan get, verify and parse certificate on the certificate from network://ip:port.

type PubKey

type PubKey struct {
	Algo x509.PublicKeyAlgorithm
	Key  any // *rsa.PublicKey, *ed25519.PublicKey, ...
}

Jump to

Keyboard shortcuts

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