當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Verifier.MarshalKey方法代碼示例

本文整理匯總了Golang中github.com/jlmucb/cloudproxy/go/tao.Verifier.MarshalKey方法的典型用法代碼示例。如果您正苦於以下問題:Golang Verifier.MarshalKey方法的具體用法?Golang Verifier.MarshalKey怎麽用?Golang Verifier.MarshalKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/jlmucb/cloudproxy/go/tao.Verifier的用法示例。


在下文中一共展示了Verifier.MarshalKey方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RequestProgramCert

// This function packages a host attestation into a DomainServiceRequest of the type
// DOMAIN_CERT_REQUEST, sends it to the domain service and deserializes the response
// into an attestation that contains the domain program certificate.
func RequestProgramCert(hostAtt *tao.Attestation, verifier *tao.Verifier,
	network string, addr string) (*x509.Certificate, error) {
	serAtt, err := proto.Marshal(hostAtt)
	if err != nil {
		return nil, err
	}
	reqType := DomainServiceRequest_DOMAIN_CERT_REQUEST
	request := &DomainServiceRequest{
		Type: &reqType,
		SerializedHostAttestation: serAtt,
		ProgramKey:                verifier.MarshalKey(),
	}

	conn, err := net.Dial(network, addr)
	if err != nil {
		return nil, err
	}
	ms := util.NewMessageStream(conn)
	_, err = ms.WriteMessage(request)
	if err != nil {
		return nil, err
	}
	log.Printf("Sent Program cert request to Domain Service using network %s at address %s.",
		network, addr)
	var response DomainServiceResponse
	err = ms.ReadMessage(&response)
	if err != nil {
		return nil, err
	}
	log.Println("Got response from Domain Service.")

	if errStr := response.GetErrorMessage(); errStr != "" {
		return nil, errors.New(errStr)
	}
	cert, err := x509.ParseCertificate(response.GetDerProgramCert())
	if err != nil {
		return nil, err
	}
	return cert, nil
}
開發者ID:tmroeder,項目名稱:cloudproxy,代碼行數:43,代碼來源:client.go


注:本文中的github.com/jlmucb/cloudproxy/go/tao.Verifier.MarshalKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。