{"modulePath":"github.com/stackdocker/consul","version":"v0.5.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tlsutil\n\n## Functions\n\n```go\nfunc WrapTLSClient(conn net.Conn, tlsConfig *tls.Config) (net.Conn, error)\n```\nWrap a net.Conn into a client tls connection, performing any additional verification as needed.\n\nAs of go 1.3, crypto/tls only supports either doing no certificate verification, or doing full verification including of the peer's DNS name. For consul, we want to validate that the certificate is signed by a known CA, but because consul doesn't use DNS names for node names, we don't verify the certificate DNS names. Since go 1.3 no longer supports this mode of operation, we have to do it manually.\n\n## Types\n\n```go\ntype Config struct {\n\t// VerifyIncoming is used to verify the authenticity of incoming connections.\n\t// This means that TCP requests are forbidden, only allowing for TLS. TLS connections\n\t// must match a provided certificate authority. This can be used to force client auth.\n\tVerifyIncoming bool\n\n\t// VerifyOutgoing is used to verify the authenticity of outgoing connections.\n\t// This means that TLS requests are used, and TCP requests are not made. TLS connections\n\t// must match a provided certificate authority. This is used to verify authenticity of\n\t// server nodes.\n\tVerifyOutgoing bool\n\n\t// VerifyServerHostname is used to enable hostname verification of servers. This\n\t// ensures that the certificate presented is valid for server.\u003cdatacenter\u003e.\u003cdomain\u003e.\n\t// This prevents a compromised client from being restarted as a server, and then\n\t// intercepting request traffic as well as being added as a raft peer. This should be\n\t// enabled by default with VerifyOutgoing, but for legacy reasons we cannot break\n\t// existing clients.\n\tVerifyServerHostname bool\n\n\t// CAFile is a path to a certificate authority file. This is used with VerifyIncoming\n\t// or VerifyOutgoing to verify the TLS connection.\n\tCAFile string\n\n\t// CertFile is used to provide a TLS certificate that is used for serving TLS connections.\n\t// Must be provided to serve TLS connections.\n\tCertFile string\n\n\t// KeyFile is used to provide a TLS key that is used for serving TLS connections.\n\t// Must be provided to serve TLS connections.\n\tKeyFile string\n\n\t// Node name is the name we use to advertise. Defaults to hostname.\n\tNodeName string\n\n\t// ServerName is used with the TLS certificate to ensure the name we\n\t// provide matches the certificate\n\tServerName string\n\n\t// Domain is the Consul TLD being used. Defaults to \"consul.\"\n\tDomain string\n}\n```\nConfig used to create tls.Config\n\n```go\nfunc (c *Config) AppendCA(pool *x509.CertPool) error\n```\nAppendCA opens and parses the CA file and adds the certificates to the provided CertPool.\n\n```go\nfunc (c *Config) IncomingTLSConfig() (*tls.Config, error)\n```\nIncomingTLSConfig generates a TLS configuration for incoming requests\n\n```go\nfunc (c *Config) KeyPair() (*tls.Certificate, error)\n```\nKeyPair is used to open and parse a certificate and key file\n\n```go\nfunc (c *Config) OutgoingTLSConfig() (*tls.Config, error)\n```\nOutgoingTLSConfig generates a TLS configuration for outgoing requests. It will return a nil config if this configuration should not use TLS for outgoing connections.\n\n```go\nfunc (c *Config) OutgoingTLSWrapper() (DCWrapper, error)\n```\nOutgoingTLSWrapper returns a a DCWrapper based on the OutgoingTLS configuration. If hostname verification is on, the wrapper will properly generate the dynamic server name for verification.\n\n```go\ntype DCWrapper func(dc string, conn net.Conn) (net.Conn, error)\n```\nDCWrapper is a function that is used to wrap a non-TLS connection and returns an appropriate TLS connection or error. This takes a datacenter as an argument.\n\n```go\ntype Wrapper func(conn net.Conn) (net.Conn, error)\n```\nWrapper is a variant of DCWrapper, where the DC is provided as a constant value. This is usually done by currying DCWrapper.\n\n```go\nfunc SpecificDC(dc string, tlsWrap DCWrapper) Wrapper\n```\nSpecificDC is used to invoke a static datacenter and turns a DCWrapper into a Wrapper type.\n\n","path":"github.com/stackdocker/consul/tlsutil","name":"tlsutil","synopsis":"","isRedistributable":true}
