Documentation
Overview ¶
Package badcerts is a library to handle bad (e.g. self-signed) certificates.
It provides a function you could use in your http.Client, to handle the case that you do not want to disable https certificate validation altogether, but you want to whitelist one (or more) bad (self-signed, expired, wrong common name, etc.) cert(s) because you have to. ¯\_(ツ)_/¯
This library is inspired by https://github.com/tam7t/hpkp
Index ¶
Examples ¶
Constants ¶
Variables ¶
Functions ¶
func DialTLSWithWhitelistCerts ¶
func DialTLSWithWhitelistCerts( errorFunc ErrorFunc, certFingerprints ...string, ) func(network, addr string) (net.Conn, error)
DialTLSWithWhitelistCerts returns a DialTLS implementation.
First it tries standard tls.Dial. If nothing is wrong, it returns the result directly.
If the error satisfies errorFunc, it dials again without cert verification, then checks the fingerprint of the cert against the given certs. If the fingerprint matches it returns the connection without error, otherwise it returns the original error when calling standard tls.Dial.
As a result this function works with all the standard trusted root CAs plus the ones with matching cert fingerprints, and nothing else.
func Fingerprint ¶
func Fingerprint(cert *x509.Certificate) string
Fingerprint returns the sha256 of an x509 certificate signature, encoded with standard base64.
func IsSelfSignedError ¶
IsSelfSignedError is an ErrorFunc returns true for self-signed certs.
Types ¶
Directories
Path | Synopsis |
---|---|
cmd
|
|
badcerts-fingerprint
Command badcerts-fingerprint provides a tool to get cert fingerprint(s) to be used in badcerts library.
|
Command badcerts-fingerprint provides a tool to get cert fingerprint(s) to be used in badcerts library. |