示例#1
0
func (client *clientImpl) storeTCertOwnerKDFKey(pwd []byte) error {
	err := ioutil.WriteFile(client.node.conf.getTCertOwnerKDFKeyPath(), utils.AEStoPEM(client.tCertOwnerKDFKey), 0700)
	if err != nil {
		client.node.log.Error("Failed storing TCertOwnerKDFKey [%s].", err.Error())
		return err
	}

	return nil
}
示例#2
0
func (node *nodeImpl) retrieveEnrollmentData(userID, pwd string) error {
	key, enrollCertRaw, enrollChainKey, err := node.getEnrollmentCertificateFromECA(userID, pwd)
	if err != nil {
		node.log.Error("Failed getting enrollment certificate [id=%s]  ", userID, err)

		return err
	}
	node.log.Debug("Enrollment certificate [%s].", utils.EncodeBase64(enrollCertRaw))
	//	validatorLogger.Info("Register:key  ", utils.EncodeBase64(key))

	// Store enrollment  key
	node.log.Debug("Storing enrollment data for user [%s]...", userID)

	rawKey, err := utils.PrivateKeyToPEM(key)
	if err != nil {
		node.log.Error("Failed converting enrollment key to PEM [id=%s]: ", userID, err)
		return err
	}

	err = ioutil.WriteFile(node.conf.getEnrollmentKeyPath(), rawKey, 0700)
	if err != nil {
		node.log.Error("Failed storing enrollment key [id=%s]: ", userID, err)
		return err
	}

	// Store enrollment cert
	err = ioutil.WriteFile(node.conf.getEnrollmentCertPath(), utils.DERCertToPEM(enrollCertRaw), 0700)
	if err != nil {
		node.log.Error("Failed storing enrollment certificate [id=%s]: ", userID, err)
		return err
	}

	// Store enrollment id
	err = ioutil.WriteFile(node.conf.getEnrollmentIDPath(), []byte(userID), 0700)
	if err != nil {
		node.log.Error("Failed storing enrollment certificate [id=%s]: ", userID, err)
		return err
	}

	// Store enrollment chain key
	err = ioutil.WriteFile(node.conf.getEnrollmentChainKeyPath(), utils.AEStoPEM(enrollChainKey), 0700)
	if err != nil {
		node.log.Error("Failed storing enrollment chain key [id=%s]: ", userID, err)
		return err
	}

	return nil
}