tlscfg

package
v0.0.0-...-6ade924 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

README

tlscfg

This package contains client TLS configuration and function to create tls.Config from it.

Every module that needs tls.Config for data collection should use it. It allows to have same set of user configurable options across all modules.

Configuration options

  • tls_skip_verify: controls whether a client verifies the server's certificate chain and host name.
  • tls_ca: certificate authority to use when verifying server certificates.
  • tls_cert: tls certificate to use.
  • tls_key: tls key to use.

Usage

Just make TLSConfig part of your module configuration.

package example

import "github.com/netdata/go.d.plugin/pkg/tlscfg"

type Config struct {
	tlscfg.TLSConfig `yaml:",inline"`
}

type Example struct {
	Config `yaml:",inline"`
}

func (e *Example) Init() bool {
	tlsCfg, err := tlscfg.NewTLSConfig(e.TLSConfig)
	if err != nil {
		// ...
		return false
	}

	// ...
	return true
}

Having TLSConfig embedded your configuration inherits all configuration options:

jobs:
  - name: name
    tls_skip_verify: no
    tls_ca: path/to/ca.pem
    tls_cert: path/to/cert.pem
    tls_key: path/to/key.pem

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTLSConfig

func NewTLSConfig(cfg TLSConfig) (*tls.Config, error)

NewTLSConfig creates a tls.Config, may be nil without an error if TLS is not configured.

Types

type TLSConfig

type TLSConfig struct {
	// TLSCA specifies the certificate authority to use when verifying server certificates.
	TLSCA string `yaml:"tls_ca"`

	// TLSCert specifies tls certificate file.
	TLSCert string `yaml:"tls_cert"`

	// TLSKey specifies tls key file.
	TLSKey string `yaml:"tls_key"`

	// InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name.
	InsecureSkipVerify bool `yaml:"tls_skip_verify"`
}

TLSConfig represents the standard client TLS configuration.

Jump to

Keyboard shortcuts

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