func (a *Agent) UseKey(key string) (*structs.KeyringResponses, error) {
	args := structs.KeyringRequest{Key: key, Operation: structs.KeyringUse}
	return a.keyringProcess(&args)
}
UseKey changes the primary encryption key used to encrypt messages
package agent
import (
	"encoding/base64"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/hashicorp/consul/consul/structs"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/hashicorp/memberlist"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/hashicorp/serf/serf"
)
const (
	serfLANKeyring = "serf/local.keyring"
	serfWANKeyring = "serf/remote.keyring"
)
func initKeyring(path, key string) error {
	var keys []string
	if _, err := base64.StdEncoding.DecodeString(key); err != nil {
		return fmt.Errorf("Invalid key: %s", err)
	}
	if _, err := os.Stat(path); err == nil {
		return nil
	}
	keys = append(keys, key)
	keyringBytes, err := json.Marshal(keys)
	if err != nil {
		return err
	}
	if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
		return err
	}
	fh, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
	if err != nil {
		return err
	}
	defer fh.Close()
	if _, err := fh.Write(keyringBytes); err != nil {
		os.Remove(path)
		return err
	}
	return nil
}
func loadKeyringFile(c *serf.Config) error {
	if c.KeyringFile == "" {
		return nil
	}
	if _, err := os.Stat(c.KeyringFile); err != nil {
		return err
	}
	keyringData, err := ioutil.ReadFile(c.KeyringFile)
	if err != nil {
		return err
	}
	keys := make([]string, 0)
	if err := json.Unmarshal(keyringData, &keys); err != nil {
		return err
	}
	keysDecoded := make([][]byte, len(keys))
	for i, key := range keys {
		keyBytes, err := base64.StdEncoding.DecodeString(key)
		if err != nil {
			return err
		}
		keysDecoded[i] = keyBytes
	}
	if len(keysDecoded) == 0 {
		return fmt.Errorf("no keys present in keyring file: %s", c.KeyringFile)
	}
	keyring, err := memberlist.NewKeyring(keysDecoded, keysDecoded[0])
	if err != nil {
		return err
	}
	c.MemberlistConfig.Keyring = keyring
	return nil
}
func (a *Agent) keyringProcess(args *structs.KeyringRequest) (*structs.KeyringResponses, error) {
	var reply structs.KeyringResponses
	if a.server == nil {
		return nil, fmt.Errorf("keyring operations must run against a server node")
	}
	if err := a.RPC("Internal.KeyringOperation", args, &reply); err != nil {
		return &reply, err
	}
	return &reply, nil
}
func (a *Agent) ListKeys() (*structs.KeyringResponses, error) {
	args := structs.KeyringRequest{Operation: structs.KeyringList}
	return a.keyringProcess(&args)
}
func (a *Agent) InstallKey(key string) (*structs.KeyringResponses, error) {
	args := structs.KeyringRequest{Key: key, Operation: structs.KeyringInstall}
	return a.keyringProcess(&args)
}