func TLSConfig(cert *sm2.Certificate, serverName string, config apiconfig.Config) (*tls.Config, error) {
	certPool, _ := config.TLSCACertPool()
	if cert == nil && (certPool == nil || len(certPool.Subjects()) == 0) {
		return nil, errors.New("certificate is required")
	}
	tlsCaCertPool, err := config.TLSCACertPool(cert)
	if err != nil {
		return nil, err
	}
	clientCerts, err := config.TLSClientCerts()
	if err != nil {
		return nil, errors.Errorf("Error loading cert/key pair for TLS client credentials: %v", err)
	}
	return &tls.Config{RootCAs: tlsCaCertPool, Certificates: clientCerts, ServerName: serverName}, nil
}
TLSConfig returns the appropriate config for TLS including the root CAs,
certs for mutual TLS, and server host override. Works with certs loaded either from a path or embedded pem.
package comm
import (
	"github.com/hyperledger/fabric-sdk-go/api/apiconfig"
	cutil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/common/util"
	"github.com/pkg/errors"
	"github.com/hyperledger/fabric-sdk-go/internal/github.com/tjfoc/gmsm/sm2"
	tls "github.com/hyperledger/fabric-sdk-go/internal/github.com/tjfoc/gmtls"
)