A method for implementing TCP secure long connection on a browser
By setting up a WebSocket network proxy connection server on the browser for security verification and data forwarding, the problem of traditional browsers being unable to implement Socket-TCP connections is solved, thus achieving a secure and compatible TCP connection service.
Patent Information
- Application Number
- CN202410527577.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2044-04-29
AI Technical Summary
Traditional browsers cannot directly implement Socket-TCP connections, which limits their application scope in the field of network communication.
By setting up a WebSocket network proxy connection server, security verification and data forwarding are performed to realize the proxy function from WebSocket to TCP, including SSL/TLS encryption and client authentication, ensuring the security and legitimacy of the connection.
It enables secure TCP connections to servers from within a browser, providing a secure connection service that does not require users to install a client, and offers good compatibility and ease of maintenance.
Smart Images

Figure CN118353888B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of emerging information technology, and in particular to a method for implementing a secure long-lived TCP connection in a browser. Background Technology
[0002] Currently, browsers primarily rely on Web-Socket technology to establish network connections. Although Web-Socket provides real-time, bidirectional communication capabilities, it is not the only or universal solution. In fact, many network services still rely on Socket-TCP connections. This connection method has significant advantages in terms of data transmission efficiency and stability. However, due to security restrictions and architectural design, traditional browsers cannot directly implement Socket-TCP connection capabilities. This limits the application scope of browsers in the field of network communication to some extent, making it impossible for some services based on Socket-TCP connections to run directly in the browser.
[0003] In view of the above-mentioned shortcomings, a method for implementing secure long-lived TCP connections in a browser is proposed. Summary of the Invention
[0004] The purpose of this section is to outline some aspects of embodiments of the present invention and to briefly describe some preferred embodiments. Simplifications or omissions may be made in this section, as well as in the abstract and title of this application, to avoid obscuring the purpose of these documents; however, such simplifications or omissions should not be construed as limiting the scope of the invention.
[0005] In view of the above problems, the present invention is proposed.
[0006] Therefore, the purpose of this invention is to provide a method for implementing secure long-lived TCP connections in a browser, which solves the problem that traditional browsers cannot implement Socket-TCP connections.
[0007] To solve the above technical problems, the present invention provides the following technical solution: a method for implementing a secure long-lived TCP connection in a browser, comprising the following steps:
[0008] S1 sets up a WebSocket network proxy connection server to provide WebSocket connection listening service;
[0009] S2, when a WebSocket connection request is received, performs a security check to ensure that the request is from a trusted end;
[0010] S3, begins by connecting the WebSocket connection to the target service via TCP and forwarding the transmitted data;
[0011] S4 tracks the status of each connection and cleans it up when a connection is closed.
[0012] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the security verification specifically includes WebSocket connection encryption and client authentication.
[0013] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the WebSocket connection is specifically encrypted using SSL / TLS encryption.
[0014] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the client authentication specifically involves: when establishing a WebSocket connection, using client credentials, the server verifies the credentials to determine the client's identity.
[0015] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the client credentials include a username, a password, and an API key.
[0016] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the security verification further includes server-side authentication.
[0017] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the server authentication specifically involves: after the WebSocket connection is established, the server verifies the legitimacy of the client connection.
[0018] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the specific method for verifying the legitimacy of the client connection is to verify it through a token, digital signature, and IP address whitelist.
[0019] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the security verification further includes verifying data integrity during data transmission.
[0020] As a preferred embodiment of the method for implementing a secure long-lived TCP connection in a browser according to the present invention, the data integrity verification is specifically performed using MD5.
[0021] The beneficial effects of this invention are:
[0022] 1. A solution for implementing secure TCP connections in a browser is proposed, which fulfills the requirement of directly connecting to the server via TCP on a webpage. Compared with the current project status, it enables secure TCP connection services without requiring users to install a client.
[0023] 2. The method proposed in this invention is based entirely on the underlying network protocol transmission, which can achieve maximum compatibility, minimal modification, and ease of maintenance. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0025] Figure 1 This is a flowchart illustrating the framework of a method for implementing a secure long-lived TCP connection in a browser according to the present invention. Detailed Implementation
[0026] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0027] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0028] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0029] Secondly, the present invention is described in detail with reference to the schematic diagrams. When detailing the embodiments of the present invention, for ease of explanation, the cross-sectional views illustrating the device structure may be partially enlarged, not according to the usual scale. Furthermore, the schematic diagrams are merely examples and should not limit the scope of protection of the present invention. In addition, actual fabrication should include the three-dimensional spatial dimensions of length, width, and depth.
[0030] Example 1
[0031] A method for implementing a secure long-lived TCP connection in a browser includes the following steps:
[0032] S1 sets up a WebSocket network proxy connection server to provide WebSocket connection listening service;
[0033] S2, when a WebSocket connection request is received, performs a security check to ensure that the request is from a trusted end;
[0034] S3, begins by connecting the WebSocket connection to the target service via TCP and forwarding the transmitted data;
[0035] S4 tracks the status of each connection and cleans it up when a connection is closed.
[0036] The security verification specifically includes WebSocket connection encryption and client authentication. The WebSocket connection encryption method is to use SSL / TLS encryption. The client authentication method is to use client credentials when establishing a WebSocket connection. The server verifies the credentials to determine the client's identity. The client credentials include username, password and API key.
[0037] It should be noted that once a WebSocket connection is established, the server will act as a proxy between WebSocket and TCP. When the client sends data to the WebSocket connection, the server will receive the data and forward it to the TCP connection. Similarly, when the server receives data from the TCP connection, it will forward it to the WebSocket connection.
[0038] In addition, the server will also act as a proxy from TCP to WebSocket. When the server receives data from the TCP connection, it will forward it to the WebSocket connection. Similarly, when the client receives data from the WebSocket connection, the server will receive the data and forward it to the TCP connection.
[0039] Example 2
[0040] A method for implementing a secure long TCP connection in a browser, which, based on embodiment 1, further includes server-side authentication for security verification. Specifically, after the WebSocket connection is established, the server verifies the legitimacy of the client connection.
[0041] Specifically, the method for verifying the legitimacy of a client connection is through verification using tokens, digital signatures, and IP address whitelists.
[0042] In addition, security verification also includes verifying data integrity during data transmission, specifically by using MD5 for verification.
[0043] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for implementing TCP secure long connection on a browser, characterized in that, The method comprises the following steps: S1, building a WebSocket network proxy connection server to provide WebSocket connection listening service; S2, when receiving a WebSocket connection request, performing security check to ensure that the request is from a trusted end; S3, starting to connect the WebSocket to a target service through TCP connection and forwarding transmission data; S4, tracking the state of each connection and cleaning up when the connection is closed; The security check specifically comprises WebSocket connection encryption and client authentication; The security check further comprises server authentication; The security check further comprises data integrity check during data transmission.
2. The method for implementing TCP secure long connection on a browser according to claim 1, characterized in that: The WebSocket connection encryption specifically uses SSL / TLS encryption.
3. The method for implementing TCP secure long connection on a browser according to claim 1, characterized in that, The client authentication specifically uses client credentials to verify the credentials of the server to determine the identity of the client when establishing a WebSocket connection.
4. The method for implementing TCP secure long connection on a browser according to claim 3, characterized in that: The client credentials include a username, a password, and an API key.
5. The method for implementing TCP secure long connection on browser according to claim 1, characterized in that, The server authentication specifically verifies the legality of the client connection after establishing a WebSocket connection.
6. The method for implementing TCP secure long connection on a browser according to claim 5, characterized in that: The specific way to verify the legality of the client connection is to verify through a token, a digital signature, and an IP address whitelist.
7. The method for implementing TCP secure long connection on browser according to claim 1, characterized in that: The data integrity check specifically uses MD5 for check.
Citation Information
Patent Citations
Method for directly communicating browser client with back-end server as well as gateway and communication system
CN102546794A
Remote interaction method and device
CN111212117A