Exemplo n.º 1
0
func storePrivateKeyInClear(alias string, privateKey interface{}, t *testing.T) {
	rawKey, err := utils.PrivateKeyToPEM(privateKey, nil)
	if err != nil {
		t.Logf("Failed converting private key to PEM [%s]: [%s]", alias, err)
		t.Fail()
	}

	err = ioutil.WriteFile(filepath.Join(".membersrvc/", alias), rawKey, 0700)
	if err != nil {
		t.Logf("Failed storing private key [%s]: [%s]", alias, err)
		t.Fail()
	}
}
Exemplo n.º 2
0
func (ks *keyStore) storePrivateKeyInClear(alias string, privateKey interface{}) error {
	rawKey, err := utils.PrivateKeyToPEM(privateKey, nil)
	if err != nil {
		ks.node.error("Failed converting private key to PEM [%s]: [%s]", alias, err)
		return err
	}

	err = ioutil.WriteFile(ks.node.conf.getPathForAlias(alias), rawKey, 0700)
	if err != nil {
		ks.node.error("Failed storing private key [%s]: [%s]", alias, err)
		return err
	}

	return nil
}