Documentation
¶
Index ¶
- Constants
- Variables
- func CertsToTables(w io.Writer, certs []*x509.Certificate)
- func GetCertsFromBundle(certBundlePath string, fileReader Reader) ([]*x509.Certificate, error)
- func GetKeyFromFile(keyFilePath string, keyPwEnvVar string, inputReader Reader) (crypto.PrivateKey, error)
- func GetRootCertsFromFile(caBundlePath string, fileReader Reader) (*x509.CertPool, error)
- func GetRootCertsFromString(caBundleString string) (*x509.CertPool, error)
- func IsPrivateKeyEncrypted(key []byte) (bool, error)
- func ParsePrivateKey(keyPEM []byte, pwEnvKey string, pwReader Reader) (crypto.PrivateKey, error)
- func PrintCertInfo(cert *x509.Certificate, depth int, w io.Writer)
- type CertinfoConfig
- func (c *CertinfoConfig) GetRemoteCerts() error
- func (c *CertinfoConfig) PrintData(w io.Writer) error
- func (c *CertinfoConfig) SetCaPoolFromFile(filePath string, fileReader Reader) error
- func (c *CertinfoConfig) SetCertsFromFile(filePath string, fileReader Reader) error
- func (c *CertinfoConfig) SetPrivateKeyFromFile(filePath string, keyPwEnvVar string, fileReader Reader) error
- func (c *CertinfoConfig) SetTLSEndpoint(hostport string) error
- func (c *CertinfoConfig) SetTLSInsecure(skipVerify bool) *CertinfoConfig
- func (c *CertinfoConfig) SetTLSServerName(serverName string) *CertinfoConfig
- type InputReader
- type Reader
Constants ¶
const ( TLSTimeout = 3 * time.Second CertExpWarnDays = 40 )
Variables ¶
var ( TlsServerName string TlsInsecure bool )
Functions ¶
func CertsToTables ¶
func CertsToTables(w io.Writer, certs []*x509.Certificate)
func GetCertsFromBundle ¶
func GetCertsFromBundle(certBundlePath string, fileReader Reader) ([]*x509.Certificate, error)
func GetKeyFromFile ¶
func GetRootCertsFromFile ¶
func GetRootCertsFromString ¶
func IsPrivateKeyEncrypted ¶
IsPrivateKeyEncrypted checks if the given PEM key is encrypted. It returns true if encrypted, false otherwise, and an error if decoding fails.
func ParsePrivateKey ¶
ParsePrivateKey parses a PEM-encoded private key and returns it as a crypto.PrivateKey.
Supported formats:
- PKCS#8 ("BEGIN PRIVATE KEY" / "BEGIN ENCRYPTED PRIVATE KEY") — decrypted with github.com/youmark/pkcs8
- PKCS#1 RSA ("BEGIN RSA PRIVATE KEY") — cleartext or PEM-encrypted (x509.DecryptPEMBlock)
- EC private keys ("BEGIN EC PRIVATE KEY") — cleartext or certain PKCS#8-encrypted ECDSA keys
If the PEM is encrypted the function will try to read the passphrase from the environment variable named by pwEnvKey; if that is empty it will prompt the user interactively.
The function returns a descriptive error if the PEM cannot be decoded, decryption/parsing fails, or the key format is unsupported.
func PrintCertInfo ¶
func PrintCertInfo(cert *x509.Certificate, depth int, w io.Writer)
Types ¶
type CertinfoConfig ¶
type CertinfoConfig struct {
CACertsPool *x509.CertPool
CACertsFilePath string
CertsBundle []*x509.Certificate
CertsBundleFilePath string
CertsBundleFromKey bool
PrivKey crypto.PrivateKey
PrivKeyFilePath string
TLSEndpoint string
TLSEndpointHost string
TLSEndpointPort string
TLSEndpointCerts []*x509.Certificate
TLSEndpointCertsFromKey bool
TLSServerName string
TLSInsecure bool
}
func NewCertinfoConfig ¶
func NewCertinfoConfig() (*CertinfoConfig, error)
func (*CertinfoConfig) GetRemoteCerts ¶
func (c *CertinfoConfig) GetRemoteCerts() error
func (*CertinfoConfig) SetCaPoolFromFile ¶
func (c *CertinfoConfig) SetCaPoolFromFile(filePath string, fileReader Reader) error
func (*CertinfoConfig) SetCertsFromFile ¶
func (c *CertinfoConfig) SetCertsFromFile(filePath string, fileReader Reader) error
func (*CertinfoConfig) SetPrivateKeyFromFile ¶
func (c *CertinfoConfig) SetPrivateKeyFromFile( filePath string, keyPwEnvVar string, fileReader Reader, ) error
func (*CertinfoConfig) SetTLSEndpoint ¶
func (c *CertinfoConfig) SetTLSEndpoint(hostport string) error
func (*CertinfoConfig) SetTLSInsecure ¶
func (c *CertinfoConfig) SetTLSInsecure(skipVerify bool) *CertinfoConfig
func (*CertinfoConfig) SetTLSServerName ¶
func (c *CertinfoConfig) SetTLSServerName(serverName string) *CertinfoConfig
type InputReader ¶
type InputReader struct{}
func (InputReader) ReadPassword ¶
func (InputReader) ReadPassword(fd int) ([]byte, error)