Esempio n. 1
0
func storePrivateKeyInClear(alias string, privateKey interface{}, t *testing.T) {
	rawKey, err := primitives.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()
	}
}
Esempio n. 2
0
func (ks *keyStore) storePrivateKeyInClear(alias string, privateKey interface{}) error {
	rawKey, err := primitives.PrivateKeyToPEM(privateKey, nil)
	if err != nil {
		ks.node.Errorf("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.Errorf("Failed storing private key [%s]: [%s]", alias, err)
		return err
	}

	return nil
}