Re: how to obtain an org's root CA certificate in application chaincode?

qs meng <qsmeng@...>

Thank you, Baohua.
Yes, if chaincodes only use stub api, they can not get the msp from peer. But can chaincodes get msp through other ways? For example, through using go-sdk or through using functions in fabric package?
Thank you.
qs meng

At 2019-05-06 16:46:16, "Baohua Yang" <yangbaohua@...> wrote:
The chaincode cannot get the msp info from peer.

You can only use the stub APIs in chaincode.

On Mon, May 6, 2019 at 12:07 PM qs meng <qsmeng@...> wrote:
    suppose one application certificate is issued by one fabric org's ca and the certificate needs being verified in  an application chaincode. 
    One way is to get the org's root ca certificate. But I do not know how to obtain the root certificate.
     Another way:  similar to forming a proposal, the application certificate is passed in chaincde as a creator,  and  use identity.Validate() to validate.  To do that, the chaincode including the following code:
      channelID := stub.GetChannelID()
     creatorByte, _ := stub.GetCreator()
     mspObj := mspmgmt.GetIdentityDeserializer(channelID)
     creator, err := mspObj.DeserializeIdentity(creatorByte)
     err = creator.Validate()
    return shim.Error("[error] return:" + err.Error())
after the successful import mgmt package and instantiation, the chaincode runs timeout.
  How to solve this problem? Thank you.
  Best regards,
qs meng


Best wishes!

Baohua Yang


Join to automatically receive all group messages.