加密ServiceStack ServerEventsClient消息传递

时间:2016-02-21 04:21:08

标签: c# .net servicestack httpserver

我正在尝试使用ServerEventsClient在我的服务器和客户端之间保护消息传递。在我的服务器上,我注册了相应的功能并创建了密钥对。问题出在客户端内 - 我无法从ServerEventsClient创建EncryptedClient。

var client = new ServerEventsClient("http://localhost:1337/", "home")
{
    OnConnect = OnConnect,
    OnCommand = HandleIncomingCommand,
    OnMessage = HandleIncomingMessage,
    OnException = OnException,
    OnHeartbeat = OnHeartbeat
};

var publicKey = client.ServiceClient.Get(new GetPublicKey());

我可以成功获得密钥,但没有像

这样的东西
client.GetEncryptedClient(publicKey);

client.ServiceCLient.GetEncryptedClient(publicKey);

此时是否有办法保护我的消息?

1 个答案:

答案 0 :(得分:1)

ServiceStack的Encrypted Messaging Feature仅限于正常的请求/回复服务,其中请求和响应DTO以加密消息的形式发送。

ServiceStack的Server Events直接写入响应输出流,即没有加密。由于通知是以明文形式发送的,因此您需要限制它们发送只有“ID”引用的通知,这些引用将通过加密客户端访问客户端的敏感信息。