lxd/util/net.go
func ServerTLSConfig(cert *shared.CertInfo) *tls.Config {
	config := shared.InitTLSConfig()
	config.ClientAuth = tls.RequestClientCert
	config.Certificates = []tls.Certificate{cert.KeyPair()}
	config.NextProtos = []string{"h2"} // Required by gRPC

	if cert.CA() != nil {
		pool := x509.NewCertPool()
		pool.AddCert(cert.CA())
		config.RootCAs = pool
		config.ClientCAs = pool

		logger.Infof("LXD is in CA mode, only CA-signed certificates will be allowed")
	}

	config.BuildNameToCertificate()
	return config
}
func ServerTLSConfig(cert *shared.CertInfo) *tls.Config {
	config := shared.InitTLSConfig()
	config.ClientAuth = tls.RequestClientCert
	config.Certificates = []tls.Certificate{cert.KeyPair()}
	config.NextProtos = []string{"h2"} // Required by gRPC

	if cert.CA() != nil {
		pool := x509.NewCertPool()
		pool.AddCert(cert.CA())
		config.RootCAs = pool
		config.ClientCAs = pool

		logger.Infof("LXD is in CA mode, only CA-signed certificates will be allowed")
	}

	config.BuildNameToCertificate()
	return config
}
func ServerTLSConfig ( cert * shared . CertInfo ) * tls . Config { config := shared . InitTLSConfig ( ) config . ClientAuth = tls . RequestClientCert config . Certificates = [ ] tls . Certificate { cert . KeyPair ( ) } config . NextProtos = [ ] string { " " } // Required by gRPC if cert . CA ( ) != nil { pool := x509 . NewCertPool ( ) pool . AddCert ( cert . CA ( ) ) config . RootCAs = pool config . ClientCAs = pool logger . Infof ( " " ) } config . BuildNameToCertificate ( ) return config }
// ServerTLSConfig returns a new server-side tls.Config generated from the give
// certificate info.
ServerTLSConfig returns a new server - side tls . Config generated from the give certificate info .