本文整理匯總了Golang中github.com/hyperledger/fabric/core/crypto.Client.GetTCertificateHandlerFromDER方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.GetTCertificateHandlerFromDER方法的具體用法?Golang Client.GetTCertificateHandlerFromDER怎麽用?Golang Client.GetTCertificateHandlerFromDER使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/core/crypto.Client
的用法示例。
在下文中一共展示了Client.GetTCertificateHandlerFromDER方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: EXP_ProduceSigma
// EXP_ProduceSigma produces a sigma as []byte and returns in response
func (d *Devops) EXP_ProduceSigma(ctx context.Context, sigmaInput *pb.SigmaInput) (*pb.Response, error) {
var sec crypto.Client
var err error
var sigma []byte
secret := sigmaInput.Secret
type RBACMetatdata struct {
Cert []byte
Sigma []byte
}
if d.isSecurityEnabled {
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debug("Initializing secure devops using context %s", secret.EnrollId)
}
sec, err = crypto.InitClient(secret.EnrollId, nil)
defer crypto.CloseClient(sec)
if nil != err {
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}, nil
}
devopsLogger.Debug("Getting TCertHandler for id: %s, from DER = %s", secret.EnrollId, sigmaInput.AppTCert)
tcertHandler, err := sec.GetTCertificateHandlerFromDER(sigmaInput.AppTCert)
//tcertHandler, err := sec.GetTCertificateHandlerNext()
if nil != err {
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(fmt.Errorf("Error getting TCertHandler from DER: %s", err).Error())}, nil
}
tcert := sigmaInput.AppTCert //tcertHandler.GetCertificate()
sigma, err = tcertHandler.Sign(append(tcert, sigmaInput.Data...))
if nil != err {
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(fmt.Errorf("Error signing with TCertHandler from DER: %s", err).Error())}, nil
}
// Produce the SigmaOutput
asn1Encoding, err := asn1.Marshal(RBACMetatdata{Cert: tcert, Sigma: sigma})
if nil != err {
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}, nil
}
sigmaOutput := &pb.SigmaOutput{Tcert: tcert, Sigma: sigma, Asn1Encoding: asn1Encoding}
sigmaOutputBytes, err := proto.Marshal(sigmaOutput)
if nil != err {
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}, nil
}
return &pb.Response{Status: pb.Response_SUCCESS, Msg: sigmaOutputBytes}, nil
}
devopsLogger.Warning("Security NOT enabled")
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte("Security NOT enabled")}, nil
}