本文整理汇总了Golang中github.com/jlmucb/cloudproxy/go/util.MessageStream.ReadString方法的典型用法代码示例。如果您正苦于以下问题:Golang MessageStream.ReadString方法的具体用法?Golang MessageStream.ReadString怎么用?Golang MessageStream.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jlmucb/cloudproxy/go/util.MessageStream
的用法示例。
在下文中一共展示了MessageStream.ReadString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetMessage
func GetMessage(ms *util.MessageStream) (*SimpleMessage,
error) {
resp, err := ms.ReadString()
if err != nil {
return nil, err
}
msg := new(SimpleMessage)
err = proto.Unmarshal([]byte(resp), msg)
if err != nil {
return nil, errors.New("GetResponse: Can't unmarshal message")
}
return msg, nil
}
示例2: recvCredentials
func (conn *Conn) recvCredentials(ms util.MessageStream) {
m, err := ms.ReadString()
if err != nil {
return
}
if m == "delegation" {
var a Attestation
if err = ms.ReadMessage(&a); err != nil {
return
}
// Validate the peer certificate
peerCert := conn.ConnectionState().PeerCertificates[0]
p, err := ValidatePeerAttestation(&a, peerCert)
if err != nil {
ms.SetErr(err)
return
}
if conn.guard != nil {
if conn.verifier != nil {
if err = AddEndorsements(conn.guard, &a, conn.verifier); err != nil {
ms.SetErr(err)
return
}
}
if !conn.guard.IsAuthorized(p, "Connect", nil) {
ms.SetErr(errors.New("principal delegator in client attestation is not authorized to connect"))
return
}
}
conn.peer = &p
} else if m == "key" {
peerCert := conn.ConnectionState().PeerCertificates[0]
v, err := FromX509(peerCert)
if err != nil {
ms.SetErr(errors.New("can't decode key from peer certificate"))
return
}
p := v.ToPrincipal()
conn.peer = &p
} else if m == "anonymous" {
if conn.guard != nil {
err = errors.New("peer did not provide tao delegation")
ms.SetErr(err)
return
}
} else {
err = errors.New("unrecognized authentication handshake: " + m)
ms.SetErr(err)
return
}
}