本文整理匯總了Golang中github.com/pebbe/zmq4.Socket.SetCurvePublickey方法的典型用法代碼示例。如果您正苦於以下問題:Golang Socket.SetCurvePublickey方法的具體用法?Golang Socket.SetCurvePublickey怎麽用?Golang Socket.SetCurvePublickey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pebbe/zmq4.Socket
的用法示例。
在下文中一共展示了Socket.SetCurvePublickey方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestSecurityCurve
//.........這裏部分代碼省略.........
t.Fatal("NewSocket:", err)
}
err = server.SetCurveServer(1)
if err != nil {
t.Fatal("server.SetCurveServer(1):", err)
}
err = server.SetCurveSecretkey(server_secret)
if err != nil {
t.Fatal("server.SetCurveSecretkey:", err)
}
err = server.SetIdentity("IDENT")
if err != nil {
t.Fatal("server.SetIdentity:", err)
}
server.Bind("tcp://127.0.0.1:9998")
if err != nil {
t.Fatal("server.Bind:", err)
}
err = server.SetRcvtimeo(time.Second)
if err != nil {
t.Fatal("server.SetRcvtimeo:", err)
}
// Check CURVE security with valid credentials
client, err = zmq.NewSocket(zmq.DEALER)
if err != nil {
t.Fatal("NewSocket:", err)
}
err = client.SetCurveServerkey(server_public)
if err != nil {
t.Fatal("client.SetCurveServerkey:", err)
}
err = client.SetCurvePublickey(client_public)
if err != nil {
t.Fatal("client.SetCurvePublickey:", err)
}
err = client.SetCurveSecretkey(client_secret)
if err != nil {
t.Fatal("client.SetCurveSecretkey:", err)
}
err = client.Connect("tcp://127.0.0.1:9998")
if err != nil {
t.Fatal("client.Connect:", err)
}
msg, err := bounce(server, client)
if err != nil {
t.Error(msg, err)
}
err = client.Close()
client = nil
if err != nil {
t.Fatal("client.Close:", err)
}
time.Sleep(100 * time.Millisecond)
// Check CURVE security with a garbage server key
// This will be caught by the curve_server class, not passed to ZAP
garbage_key := "0000111122223333444455556666777788889999"
client, err = zmq.NewSocket(zmq.DEALER)
if err != nil {
t.Fatal("NewSocket:", err)
}
err = client.SetCurveServerkey(garbage_key)
if err != nil {