简体   繁体   English

确保节俭的沟通

[英]Securing thrift based Communication

So, i have made a thrift based program with a client and a server and client can communicate well with server. 因此,我与客户端和服务器做了一个基于节俭的程序,客户端可以与服务器很好地通信。 Now, since the data transfer will be quite crucial, I wanted some kind of security in it. 现在,由于数据传输将非常关键,因此我需要其中的某种安全性。

So, I thought of login system, but the problem is I am not storing any kind of session data on server side(I don't even know, what should i store, after all the client request come and go and there is no way to differentiate them). 所以,我想到了登录系统,但是问题是我没有在服务器端存储任何类型的会话数据(我什至不知道,在所有客户端请求来来往往之后,我应该存储什么内容,这是不可能的区分它们)。 So after much thinking, this is what i came up with 所以经过深思熟虑,这就是我想出的

  1. Using random numbers, i would generate some kind of random string when the server starts 使用随机数,服务器启动时我会生成某种随机字符串
  2. Client side will enter the username and password which will be verified at the server end using PAM authentiation(just read something about it). 客户端将输入用户名和密码,该名称和密码将在服务器端使用PAM身份验证进行验证(只需阅读有关内容)。
  3. If verified, server will just send that random generated string to the client side 如果经过验证,服务器将只将随机生成的字符串发送到客户端
  4. Client will send that string to server every time it tries to execute a RPC 客户端每次尝试执行RPC时都会将该字符串发送到服务器
  5. If verified, server will do the work, else return some error code 如果通过验证,服务器将完成工作,否则返回一些错误代码

Possible problem that i can think of 我能想到的可能的问题

Currently, when server goes down, and client was in midst of some RPC, it would give some error message and when server restarts, we can do the task without any problem 当前,当服务器关闭并且客户端处于某个RPC中时,它将给出一些错误消息,并且当服务器重新启动时,我们可以毫无问题地完成任务

Now, if the server goes down, then the string generated will be different. 现在,如果服务器出现故障,则生成的字符串将有所不同。 So i will again have to do the authentication part 所以我将不得不再次进行身份验证部分

So, what do you think of this entire schema for authentication? 那么,您如何看待整个认证模式? Are there any better or simpler way? 有没有更好或更简单的方法?

PS : I am not using any kind of database. PS:我没有使用任何数据库。 I am using C++ on both sides. 我在两面都使用C ++。 My Client side uses QT 我的客户端使用QT

Disclaimer - I do not have much idea as to how PAM works, so I only have some high-level questions about this approach. 免责声明-我对PAM的工作原理并不了解,所以我对这种方法只提出了一些高级问题。 I apologize in advance if I misunderstood any part of your approach. 如果我误解了您的做法的任何部分,我谨此致歉。

When you say you want to secure the data transfer, I feel like you want to have authentication and secrecy, you only have an approach for authentication now. 当您说要保护数据传输安全时,我觉得您想拥有身份验证和保密性,现在您只有一种身份验证方法。

For instance, if client C1 is authenticating to server(assuming credentials are not sent in cleartext), the server sends the random string in step 3. What happens when someone else is sniffing on the network? 例如,如果客户端C1正在向服务器进行身份验证(假设凭据未以明文形式发送),则服务器将在步骤3中发送随机字符串。当其他人在网络上进行嗅探时会发生什么? Can a rogue client not send the random string and perform RPC calls to the server, posing as C1? 流氓客户端是否可以不发送随机字符串并以C1身份对服务器执行RPC调用? If username and password are sent to server in cleartext, can someone on the network get access to the credentials also? 如果用户名和密码以明文形式发送到服务器,网络上的某人是否也可以访问凭据? Also, what about data that is subsequently sent? 另外,随后发送的数据又如何呢? It is just encoded in thrift format and can be decoded by anyone on the network, correct? 它只是以节俭格式编码的,并且可以被网络上的任何人解码,对吗? Is the data sensitive? 数据敏感吗?

If so, I want to suggest the use of PKI/certificates. 如果是这样,我想建议使用PKI /证书。 Using a self-signed certificate must be fine. 使用自签名证书必须可以。 If you only want the client to authenticate to the server and prove it is legitimate, you can make all the clients present their certificate. 如果只希望客户端对服务器进行身份验证并证明它是合法的,则可以使所有客户端出示其证书。 Certificate is basically a public key for that client signed by an authority that vouches for that client.The client has the private key stored locally, that will never leave the client. 证书从根本上说是该客户端的公共密钥,由为其提供担保的授权机构签名。该客户端具有本地存储的私钥,永远不会离开该客户端。 Now, when client presents the certificate to server, server looks at who signed the certificate(CA). 现在,当客户端将证书提供给服务器时,服务器将查看谁签署了证书(CA)。 If it is a CA the server trusts, it can send the random string or just the thrift data directly, encrypted using the client's public key. 如果它是服务器信任的CA,它可以直接发送随机字符串或仅发送节俭数据,并使用客户端的公共密钥进行加密。 The client will be able to decrypt with its private key and it looks like random bytes to anyone else who is sniffing. 客户端将能够使用其私钥解密,并且对任何嗅探的人来说,它看起来都是随机字节。 The server will do this for every single client and only needs to store the name of the certifying authority it trusts. 服务器将为每个客户端执行此操作,并且只需要存储其信任的证书颁发机构的名称。 This could be your name and address. 这可能是您的姓名和地址。 You can generate the self-signed certificate on every client using openssl. 您可以使用openssl在每个客户端上生成自签名证书。 But this means you have additional setup work on each client. 但这意味着您需要在每个客户端上进行其他设置。 Generate a key-pair and certificate. 生成密钥对和证书。 You can explore this approach if this constraint works for you. 如果此约束适合您,则可以探索这种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM