gpt4 book ai didi

How do I make sure my PC program is receiving socketio events from my phone?(如何确保我的PC程序正在从我的手机接收Socketio事件?)

转载 作者:bug小助手 更新时间:2023-10-25 17:30:39 25 4
gpt4 key购买 nike




I have a C# program, and a flutter application that runs on mobiles. They communicate through a python socketio server.

我有一个C#程序,和一个在手机上运行的颤振应用程序。它们通过python socketio服务器进行通信。


The C# program and flutter app exchange data first by entering a room inside the socketio server: I generate a random string inside the C# program and create a room with that string. Then, I scan a QR code on my phone that has that string, and the flutter app joins the same room.

C#程序和Ffltter应用程序首先通过进入Socketio服务器中的一个房间来交换数据:我在C#程序中生成一个随机字符串,并使用该字符串创建一个房间。然后,我扫描手机上的二维码,上面有这个字符串,颤动应用程序就会进入同一个房间。


Then, they start exchanging data. For example, I send a socketio event from my phone, the python server receives that event and broadcasts it to the room which my C# program picks it up and performs something (such as "stress_test" event where the C# program runs some code to stress test the RAM).

然后,他们开始交换数据。例如,我从我的手机发送一个Socketio事件,Python服务器接收该事件并将其广播到房间,我的C#程序获取该事件并执行某些操作(例如C#程序运行一些代码来对RAM进行压力测试的“Stress_test”事件)。


Now, I want to make sure that these events are coming from my phone and not from someone who randomly joined the room. I don't even want the server to understand what these data are, for security reasons.

现在,我想确保这些事件来自我的手机,而不是来自随机进入房间的人。出于安全原因,我甚至不想让服务器了解这些数据是什么。


What I've tried: use AES encryption. But I don't really know how to use it in my case...

我尝试过的方法:使用AES加密。但我真的不知道如何在我的情况下使用它。


Let's say I scan the QR code inside the app: the flutter app gets the room name and the AES passkey from the QR code. Then, I use that passkey to encrypt data and send it to the program. But what data should be encrypted? Because I'm just triggering socketio events and you can't encrypt that.

假设我扫描应用程序内部的二维码:Ffltter应用程序从二维码中获取房间名称和AES密钥。然后,我使用该密钥加密数据并将其发送到程序。但是,哪些数据应该加密呢?因为我只是在触发Socketio事件,而你不能加密它。


I'm really ignorant when it comes to cyber security, maybe there's a tech that I don't know about. I'd really appreciate some guidance.

当谈到网络安全时,我真的很无知,也许有一种技术我不知道。如果您能给我一些指导,我将不胜感激。


EDIT: I thought about doing something else, I wanted to change every socketio event into one event (such as an "event_trigger"), and put the actual event name inside the data which is encrypted.

编辑:我想做一些其他的事情,我想将每个Socketio事件更改为一个事件(例如“EVENT_TRIGGER”),并将实际的事件名称放入加密的数据中。


For example:

例如:


event name: event_trigger
data: *encrypted data*

Where the data contains the actual event.
But someone else can join the room, get the event, and re-send the data to trigger a stress test without the user's content.

其中数据包含实际事件。但其他人可以加入房间,获得事件,然后重新发送数据以在没有用户内容的情况下触发压力测试。


更多回答

You might want to consider using mutual TLS (mTLS) with python's socket object. This way, in addition to the client authenticating the server by way of the server's certificate, the opposite takes place as well - i.e. the server authenticates the client by was of the certificate that the client presents to the server. The server can refuse connections from any client that does not present a certificate that the server recognizes. See docs.python.org/3/library/ssl.html for more info.

您可能需要考虑将Mutual TLS(MTLS)与python的Socket对象一起使用。这样,除了客户端通过服务器的证书对服务器进行身份验证之外,还会发生相反的情况--即服务器通过客户端向服务器提供的证书对客户端进行身份验证。服务器可以拒绝来自不提供服务器识别的证书的任何客户端的连接。有关更多信息,请参见docs.python.org/3/库/ssl.html。

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com