github.com/netdata/go.d.plugin@v0.58.1/pkg/tlscfg/README.md (about)

     1  <!--
     2  title: "tlscfg"
     3  custom_edit_url: "https://github.com/netdata/go.d.plugin/edit/master/pkg/tlscfg/README.md"
     4  sidebar_label: "tlscfg"
     5  learn_status: "Published"
     6  learn_rel_path: "Developers/External plugins/go.d.plugin/Helper Packages"
     7  -->
     8  
     9  # tlscfg
    10  
    11  This package contains client TLS configuration and function to create `tls.Config` from it.
    12  
    13  Every module that needs `tls.Config` for data collection should use it. It allows to have same set of user configurable
    14  options across all modules.
    15  
    16  ## Configuration options
    17  
    18  - `tls_skip_verify`: controls whether a client verifies the server's certificate chain and host name.
    19  - `tls_ca`: certificate authority to use when verifying server certificates.
    20  - `tls_cert`: tls certificate to use.
    21  - `tls_key`: tls key to use.
    22  
    23  ## Usage
    24  
    25  Just make `TLSConfig` part of your module configuration.
    26  
    27  ```go
    28  package example
    29  
    30  import "github.com/netdata/go.d.plugin/pkg/tlscfg"
    31  
    32  type Config struct {
    33  	tlscfg.TLSConfig `yaml:",inline"`
    34  }
    35  
    36  type Example struct {
    37  	Config `yaml:",inline"`
    38  }
    39  
    40  func (e *Example) Init() bool {
    41  	tlsCfg, err := tlscfg.NewTLSConfig(e.TLSConfig)
    42  	if err != nil {
    43  		// ...
    44  		return false
    45  	}
    46  
    47  	// ...
    48  	return true
    49  }
    50  ```
    51  
    52  Having `TLSConfig` embedded your configuration inherits all [configuration options](#configuration-options):
    53  
    54  ```yaml
    55  jobs:
    56    - name: name
    57      tls_skip_verify: no
    58      tls_ca: path/to/ca.pem
    59      tls_cert: path/to/cert.pem
    60      tls_key: path/to/key.pem
    61  ```