新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

Commit 06d2d137 authored by hxy's avatar hxy

fix: Delete trust root of pk mode --bug=1004738

parent f02a1b84
......@@ -440,6 +440,11 @@ func useCert(authType string) bool {
return authType == protocol.PermissionedWithCert || authType == protocol.Identity || authType == ""
}
func usePK(authType string) bool {
authType = strings.ToLower(authType)
return authType == protocol.Public
}
func wrapEventResult(f func(txSimContext protocol.TxSimContext, parameters map[string][]byte) ([]byte, error)) func(
txSimContext protocol.TxSimContext, parameters map[string][]byte) *commonPb.ContractResult {
r := func(txSimContext protocol.TxSimContext, parameters map[string][]byte) *commonPb.ContractResult {
......
......@@ -157,7 +157,28 @@ func (r *ChainTrustRootsRuntime) TrustRootDelete(txSimContext protocol.TxSimCont
return nil, err
}
trustRoots = append(trustRoots[:index], trustRoots[index+1:]...)
if usePK(chainConfig.AuthType) {
rootPem := string(params[paramNameRoot])
if utils.IsAnyBlank(rootPem) {
err = fmt.Errorf("delete trust root cert failed, require param [%s], but not found", paramNameRoot)
r.log.Error(err)
return nil, err
}
roots := trustRoots[index].Root
for ri, rt := range roots {
if rootPem == rt {
trustRoots[index].Root = append(trustRoots[index].Root[:ri], trustRoots[index].Root[ri+1:]...)
if len(trustRoots[index].Root) == 0 {
err = fmt.Errorf("delete trust root cert failed, can't delete all TrustRoot")
r.log.Error(err)
return nil, err
}
break
}
}
} else {
trustRoots = append(trustRoots[:index], trustRoots[index+1:]...)
}
// verify has consensus nodes
if useCert(chainConfig.AuthType) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment