func SetupTrust(cert, targetAddress, targetCert, targetPassword string) error {
	// Connect to the target cluster node.
	args := &lxd.ConnectionArgs{
		TLSServerCert: targetCert,
	}
	target, err := lxd.ConnectLXD(fmt.Sprintf("https://%s", targetAddress), args)
	if err != nil {
		return errors.Wrap(err, "failed to connect to target cluster node")
	}
	block, _ := pem.Decode([]byte(cert))
	if block == nil {
		return errors.Wrap(err, "failed to decode certificate")
	}
	certificate := base64.StdEncoding.EncodeToString(block.Bytes)
	post := api.CertificatesPost{
		Password:    targetPassword,
		Certificate: certificate,
	}
	fingerprint, err := shared.CertFingerprintStr(cert)
	if err != nil {
		return errors.Wrap(err, "failed to calculate fingerprint")
	}
	post.Name = fmt.Sprintf("lxd.cluster.%s", fingerprint)
	post.Type = "client"
	err = target.CreateCertificate(post)
	if err != nil && err.Error() != "Certificate already in trust store" {
		return errors.Wrap(err, "Failed to add client cert to cluster")
	}
	return nil
}
func SetupTrust(cert, targetAddress, targetCert, targetPassword string) error {
	
	args := &lxd.ConnectionArgs{
		TLSServerCert: targetCert,
	}
	target, err := lxd.ConnectLXD(fmt.Sprintf("https:
	if err != nil {
		return errors.Wrap(err, "failed to connect to target cluster node")
	}
	block, _ := pem.Decode([]byte(cert))
	if block == nil {
		return errors.Wrap(err, "failed to decode certificate")
	}
	certificate := base64.StdEncoding.EncodeToString(block.Bytes)
	post := api.CertificatesPost{
		Password:    targetPassword,
		Certificate: certificate,
	}
	fingerprint, err := shared.CertFingerprintStr(cert)
	if err != nil {
		return errors.Wrap(err, "failed to calculate fingerprint")
	}
	post.Name = fmt.Sprintf("lxd.cluster.%s", fingerprint)
	post.Type = "client"
	err = target.CreateCertificate(post)
	if err != nil && err.Error() != "Certificate already in trust store" {
		return errors.Wrap(err, "Failed to add client cert to cluster")
	}
	return nil
}
func SetupTrust ( cert , targetAddress , targetCert , targetPassword string ) error { // Connect to the target cluster node. args := & lxd . ConnectionArgs { TLSServerCert : targetCert , } target , err := lxd . ConnectLXD ( fmt . Sprintf ( " " , targetAddress ) , args ) if err != nil { return errors . Wrap ( err , " " ) } block , _ := pem . Decode ( [ ] byte ( cert ) ) if block == nil { return errors . Wrap ( err , " " ) } certificate := base64 . StdEncoding . EncodeToString ( block . Bytes ) post := api . CertificatesPost { Password : targetPassword , Certificate : certificate , } fingerprint , err := shared . CertFingerprintStr ( cert ) if err != nil { return errors . Wrap ( err , " " ) } post . Name = fmt . Sprintf ( " " , fingerprint ) post . Type = " " err = target . CreateCertificate ( post ) if err != nil && err . Error ( ) != " " { return errors . Wrap ( err , " " ) } return nil }
// SetupTrust is a convenience around ContainerServer.CreateCertificate that
// adds the given client certificate to the trusted pool of the cluster at the
// given address, using the given password.
SetupTrust is a convenience around ContainerServer . CreateCertificate that adds the given client certificate to the trusted pool of the cluster at the given address using the given password .