A communication method and device based on SSL
By parsing SSL requests and assigning them to the target thread group processing, the problem of HTTPS communication efficiency and performance improvement is solved, thread group optimization processing is realized, and communication efficiency and performance is improved.
Patent Information
- Application Number
- CN202110951713.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-18
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-08-18
AI Technical Summary
When using the HTTPS protocol for communication, the efficiency and performance of the communication process between the client and the server are difficult to improve.
After receiving the client's SSL request, it is parsed, the request type is determined, and the request type is allocated from the preset thread group to the target thread group for processing, including the first thread group for establishing the SSL connection and for use based on the SSL connections to the second thread group for communication.
The efficiency and performance of the communication process are improved, and the processing of the handshake and encrypted communication stages is optimized through thread allocation, which reduces the IO operation delay and waiting time, and improves the processing performance.
Smart Images

Figure CN113660342B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a communication method and device based on SSL. Background Art
[0002] At present, more and more users use the HTTPS protocol to communicate to improve the security of information during transmission. How to improve the efficiency and performance of the communication process between clients and servers using the HTTPS protocol is a problem that technicians have been solving. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a communication method and device based on SSL, which can parse the SSL request after receiving the SSL request sent by the client, determine the type of the SSL request, and then determine the target thread group for executing the SSL request from the preset thread group according to the type of the SSL request, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection, and then allocate the SSL request to the target thread group so that the target thread group processes the SSL request, thereby improving the efficiency and performance of the communication process.
[0004] To achieve the above objective, according to one aspect of an embodiment of the present invention, a communication method based on SSL is provided.
[0005] A communication method based on SSL in an embodiment of the present invention includes:
[0006] Receive SSL request from client;
[0007] Parse the SSL request and determine the type of SSL request;
[0008] Determining a target thread group for executing the SSL request from preset thread groups according to the type of the SSL request, wherein the preset thread group includes a first thread group for establishing an SSL connection and a second thread group for communicating based on the SSL connection;
[0009] The SSL request is assigned to the target thread group so that the target thread group processes the SSL request.
[0010] Optionally,
[0011] In a case where the type indicates that the SSL request is an SSL handshake request, determining a first thread group from preset thread groups as a target thread group for executing the SSL handshake request;
[0012] The SSL handshake request is assigned to the first thread group, so that the first thread group processes the SSL handshake request.
[0013] Optionally,
[0014] Allocating the SSL handshake request to the first thread group so that the first thread group processes the SSL handshake request, including:
[0015] When the type indicates that the SSL request is a request for establishing an SSL connection with the client, establishing an SSL connection with the client through the first thread in the first thread group;
[0016] and / or,
[0017] When the type indicates that the SSL request is an outward handshake request, the second thread in the first thread group sends an SSL handshake request to the external server indicated by the second SSL handshake request to establish an SSL connection with the external server.
[0018] Optionally,
[0019] In the case where the type indicates that the SSL request is an SSL communication request, determining a second thread group from the preset thread groups as a target thread group for executing the SSL communication request;
[0020] The SSL communication request is allocated to the second thread group so that the second thread group processes the SSL communication request.
[0021] Optionally,
[0022] Before receiving the SSL request from the client, it includes:
[0023] Determine the number of threads in the first thread group according to the number of CPU cores;
[0024] and / or,
[0025] The number of threads in the second thread group is determined according to the number of CPU cores and the network IO throughput.
[0026] Optionally,
[0027] After establishing an SSL connection with an external server, also include:
[0028] Obtain the target certificate of the external server through the SSL connection with the external server;
[0029] When the target certificate is received, the target certificate is re-issued using the preset local certificate to obtain a new target certificate;
[0030] The new target certificate is sent to the client through the first thread to establish an SSL connection with the client.
[0031] Optionally,
[0032] Parse the SSL request and determine the type of SSL request, including:
[0033] Parse the SSL request to obtain the header information of the SSL request;
[0034] Determine the type of SSL request based on the header information.
[0035] Optionally,
[0036] Assigning the SSL request to the target thread group so that the target thread group processes the SSL request, including:
[0037] Assign SSL requests to the target thread group;
[0038] Select a thread in the ready state from multiple threads of the target thread group as the target thread;
[0039] Handles SSL requests through the target thread.
[0040] To achieve the above objective, according to another aspect of an embodiment of the present invention, a communication device based on SSL is provided.
[0041] An SSL-based communication device according to an embodiment of the present invention includes a request receiving module, a parsing module, a thread group determining module, and an allocating module; wherein:
[0042] The request receiving module is used to receive the SSL request sent by the client;
[0043] A parsing module is used to parse the SSL request and determine the type of the SSL request;
[0044] A thread group determination module, configured to determine a target thread group for executing an SSL request from preset thread groups according to the type of the SSL request, wherein the preset thread group includes a first thread group for establishing an SSL connection and a second thread group for communicating based on the SSL connection;
[0045] The allocation module is used to allocate the SSL request to the target thread group so that the target thread group processes the SSL request.
[0046] To achieve the above objective, according to another aspect of an embodiment of the present invention, a communication electronic device based on SSL is provided.
[0047] An SSL-based communication electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement an SSL-based communication method according to an embodiment of the present invention.
[0048] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.
[0049] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a communication method based on SSL according to an embodiment of the present invention is implemented.
[0050] An embodiment of the above invention has the following advantages or beneficial effects: after receiving an SSL request from a client, the SSL request can be parsed to determine the type of the SSL request, and then according to the type of the SSL request, a target thread group for executing the SSL request can be determined from a preset thread group, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection, and then the SSL request is assigned to the target thread group so that the target thread group processes the SSL request, thereby improving the efficiency and performance of the communication process.
[0051] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0053] Figure 1 is a schematic diagram of main steps of a communication method based on SSL according to an embodiment of the present invention;
[0054] Figure 2 is a schematic diagram of the main steps of a method for establishing an SSL connection with a client;
[0055] Figure 3 It is a schematic diagram of a process of allocating an SSL request to a target thread group so that the target thread group processes the SSL request;
[0056] Figure 4 is a schematic diagram of main modules of a communication device based on SSL according to an embodiment of the present invention;
[0057] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0058] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0060] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.
[0061] Figure 1 It is a schematic diagram of main steps of a communication method based on SSL according to an embodiment of the present invention.
[0062] like Figure 1 As shown, a communication method based on SSL in an embodiment of the present invention mainly includes the following steps:
[0063] Step S101: receiving an SSL request sent by a client.
[0064] In the embodiment of the present invention, when using SSL for communication, we can divide the entire communication process into two stages: a handshake stage and an encrypted communication stage.
[0065] Specifically, in the handshake phase, certificate verification and key exchange are required, which all require the use of asymmetric key algorithms to encrypt and decrypt data, and these operations consume a lot of CPU resources. At the same time, the amount of data sent and received over the network is very small, so the handshake phase can be regarded as a CPU-intensive computing phase.
[0066] In the encrypted communication stage, the main tasks are data encryption and decryption, data compression, and data reception. The data encryption and decryption process uses a symmetric encryption algorithm. Compared with the asymmetric encryption algorithm, this stage has less CPU overhead, and the greater overhead lies in the transmission of network data. Therefore, the encrypted communication stage can be regarded as an IO-intensive computing stage.
[0067] Since the handshake phase can be regarded as a CPU-intensive computing phase, and the encrypted communication phase can be regarded as an IO-intensive computing phase, the SSL requests in the handshake phase and the SSL requests in the encrypted communication phase can be subsequently assigned to different thread groups for processing.
[0068] Step S102: Parse the SSL request to determine the type of the SSL request.
[0069] In the embodiment of the present invention, the type of the SSL request may be: an SSL handshake request or an SSL communication request.
[0070] In the embodiment of the present invention, the SSL request can be parsed to obtain the header information of the SSL request; the type of the SSL request can be determined according to the header information. According to the header information of the SSL request, the type of the SSL request can be determined more accurately and quickly, and then the subsequent steps can be executed more quickly, thereby improving the communication efficiency.
[0071] Step S103: according to the type of SSL request, determine a target thread group for executing the SSL request from preset thread groups, wherein the preset thread groups include a first thread group for establishing an SSL connection and a second thread group for communicating based on the SSL connection.
[0072] In an embodiment of the present invention, the preset thread group includes a first thread group for establishing an SSL connection and a second thread group for communicating based on the SSL connection. The number of threads included in the first thread group and the second thread group can be preset before receiving the SSL request sent by the client.
[0073] Specifically, before receiving the SSL request from the client, the number of threads in the first thread group can be determined according to the number of CPU cores. Similarly, before receiving the SSL request from the client, the number of threads in the second thread group can be determined according to the number of CPU cores and the network IO throughput.
[0074] In a preferred embodiment of the present invention, the number of threads in the first thread group may be equal to the number of CPU cores; and when there is no throughput pressure on the network IO throughput, the number of threads in the second thread group may be 1.5 times the number of CPU cores.
[0075] In an embodiment of the present invention, when the type indicates that the SSL request is an SSL handshake request, the first thread group is determined from the preset thread group as the target thread group for executing the SSL handshake request, and the SSL handshake request is then assigned to the first thread group so that the first thread group processes the SSL handshake request; and when the type indicates that the SSL request is an SSL communication request, the second thread group is determined from the preset thread group as the target thread group for executing the SSL communication request, and the SSL communication request is then assigned to the second thread group so that the second thread group processes the SSL communication request.
[0076] Through the above method, the processing process of SSL handshake request is separated from the processing process of SSL communication request at the thread allocation level, thereby realizing the separation of handshake stage and encryption communication stage, namely: the first thread group is specifically used to execute the CPU-intensive handshake stage, which reduces the waiting time caused by IO operation delay and improves the performance of processing SSL handshake request; the second thread group is specifically used to execute the IO-intensive encryption communication stage. Since the computational complexity of this stage itself is relatively small, it focuses more on reading and writing the network, reduces the waiting time for CPU operation and improves the efficiency of the encryption communication stage.
[0077] Since the SSL handshake request further includes: a request to establish an SSL connection with the client, and an outward handshake request indicated by the client, in a preferred embodiment of the present invention, it is possible to further determine, based on the header information of the SSL request, whether the SSL request indicated by the type is a request to establish an SSL connection with the client, or an outward handshake request.
[0078] In an embodiment of the present invention, the threads in the first thread group can be further divided into two types: a first thread and a second thread. When the type indicates that the SSL request is a request to establish an SSL connection with a client, an SSL connection can be established with the client through the first thread in the first thread group. When the type indicates that the SSL request is an outward handshake request, an SSL handshake request can be sent to an external server indicated by the second SSL handshake request through the second thread in the first thread group to establish an SSL connection with the external server.
[0079] In an embodiment of the present invention, after establishing an SSL connection with an external server, a method for establishing an SSL connection with a client is as follows: Figure 2 As shown, it mainly includes the following steps:
[0080] Step S201: obtaining a target certificate of an external server through an SSL connection with the external server;
[0081] Step S202: when the target certificate is received, the target certificate is re-issued using the preset local certificate to obtain a new target certificate;
[0082] Step S203: Send the new target certificate to the client through the first thread to establish an SSL connection with the client.
[0083] In the process of establishing an SSL connection with the client, the target certificate is re-issued using the preset local certificate to obtain a new target certificate, and the new target certificate is used to establish an SSL connection with the client, which can make the subsequent communication content between the client and the external server more secure. At this time, the communication data sent by the client is encrypted by the new target certificate. Even if the target certificate of the external server is leaked to a malicious user, the malicious user cannot use the target certificate to decrypt the communication data sent by the client, thereby effectively protecting the security of the client's sensitive information.
[0084] Step S104: Allocate the SSL request to the target thread group so that the target thread group processes the SSL request.
[0085] In an embodiment of the present invention, the SSL request is assigned to the target thread group so that the target thread group processes the SSL request as follows: Figure 3 As shown, it mainly includes the following steps:
[0086] Step S301: Allocate the SSL request to the target thread group;
[0087] Step S302: Selecting a thread in a ready state from multiple threads in the target thread group as a target thread;
[0088] Step S303: Process the SSL request through the target thread.
[0089] In the embodiment of the present invention, each thread in the target thread group corresponds to a priority; when there are multiple threads in the ready state, a thread with the highest priority is selected from the multiple threads in the ready state as the target thread to process the SSL request.
[0090] In an embodiment of the present invention, when there are multiple threads in the ready state with the highest priority, all of the multiple threads in the ready state with the highest priority are used as target threads, and a time slice round-robin scheduling strategy is used to select a target thread to process an SSL request.
[0091] It can be seen from an SSL-based communication method according to an embodiment of the present invention that the method can parse the SSL request after receiving the SSL request sent by the client, determine the type of the SSL request, and then determine the target thread group for executing the SSL request from the preset thread group according to the type of the SSL request, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection, and then the SSL request is allocated to the target thread group so that the target thread group processes the SSL request, thereby improving the efficiency and performance of the communication process.
[0092] Figure 4It is a schematic diagram of main modules of a communication device based on SSL according to an embodiment of the present invention.
[0093] like Figure 4 As shown, an SSL-based communication device 400 according to an embodiment of the present invention includes a request receiving module 401, a parsing module 402, a thread group determining module 403, and an allocating module 404; wherein:
[0094] The request receiving module 401 is used to receive the SSL request sent by the client;
[0095] The parsing module 402 is used to parse the SSL request and determine the type of the SSL request;
[0096] A thread group determination module 403 is used to determine a target thread group for executing the SSL request from preset thread groups according to the type of the SSL request, wherein the preset thread group includes a first thread group for establishing an SSL connection and a second thread group for communicating based on the SSL connection;
[0097] The allocation module 404 is used to allocate the SSL request to the target thread group so that the target thread group processes the SSL request.
[0098] In an embodiment of the present invention, when the type indicates that the SSL request is an SSL handshake request, the thread group determination module 403 is further used to: determine the first thread group from the preset thread groups as the target thread group for executing the SSL handshake request; the allocation module 404 is further used to: allocate the SSL handshake request to the first thread group so that the first thread group processes the SSL handshake request.
[0099] In the embodiment of the present invention, the allocation module 404 is further configured to: when the type indicates that the SSL request is a request to establish an SSL connection with the client, establish an SSL connection with the client through the first thread in the first thread group.
[0100] In an embodiment of the present invention, the allocation module 404 is further used to: when the type indicates that the SSL request is an outward handshake request, send an SSL handshake request to the external server indicated by the second SSL handshake request through the second thread in the first thread group to establish an SSL connection with the external server.
[0101] In an embodiment of the present invention, when the type indicates that the SSL request is an SSL communication request, the thread group determination module 403 is further used to: determine a second thread group from a preset thread group as a target thread group for executing the SSL communication request; the allocation module 404 is further used to: allocate the SSL communication request to the second thread group so that the second thread group processes the SSL communication request.
[0102] In the embodiment of the present invention, before receiving the SSL request sent by the client, the request receiving module 401 is further used to: determine the number of threads in the first thread group according to the number of CPU cores.
[0103] In the embodiment of the present invention, before receiving the SSL request sent by the client, the request receiving module 401 is further used to: determine the number of threads in the second thread group according to the number of CPU cores and the network IO throughput.
[0104] In an embodiment of the present invention, after establishing an SSL connection with an external server, the allocation module 404 is further used to: obtain a target certificate of the external server through the SSL connection with the external server; when receiving the target certificate, re-issue the target certificate using a preset local certificate to obtain a new target certificate; and send the new target certificate to the client through the first thread to establish an SSL connection with the client.
[0105] In the embodiment of the present invention, the parsing module 402 is further used to: parse the SSL request to obtain the header information of the SSL request; and determine the type of the SSL request according to the header information.
[0106] In the embodiment of the present invention, the allocation module 404 is further used to: allocate the SSL request to the target thread group; select a thread in a ready state from multiple threads in the target thread group as the target thread; and process the SSL request through the target thread.
[0107] It can be seen from an SSL-based communication device according to an embodiment of the present invention that the device can parse the SSL request after receiving the SSL request sent by the client, determine the type of the SSL request, and then determine the target thread group for executing the SSL request from the preset thread group according to the type of the SSL request, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection, and then the SSL request is allocated to the target thread group so that the target thread group processes the SSL request, thereby improving the efficiency and performance of the communication process.
[0108] Figure 5 An exemplary system architecture 500 of an SSL-based communication method or an SSL-based communication device to which an embodiment of the present invention can be applied is shown.
[0109] like Figure 5As shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and an electronic device 505. The network 504 is used to provide a medium for communication links between the terminal devices 501, 502, 503 and the electronic device 505. The network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0110] The user can use the terminal devices 501, 502, 503 to interact with the electronic device 505 through the network 504 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0111] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0112] The electronic device 505 may be a server that provides various services, such as a background management server that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The background management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.
[0113] It should be noted that the SSL-based communication method provided in the embodiment of the present invention is generally executed by the electronic device 505 , and accordingly, an SSL-based communication device is generally disposed in the electronic device 505 .
[0114] It should be understood that Figure 5 The number of terminal devices, networks and electronic devices in the embodiment is only for illustration. Any number of terminal devices, networks and electronic devices may be provided according to implementation requirements.
[0115] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0116] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0117] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0118] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0119] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0120] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0121] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a request receiving module, a parsing module, a thread group determination module, and an allocation module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the request receiving module may also be described as a "module for receiving an SSL request sent by a client".
[0122] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving an SSL request sent by a client; parsing the SSL request to determine the type of the SSL request; according to the type of the SSL request, determining a target thread group for executing the SSL request from a preset thread group, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection; allocating the SSL request to the target thread group so that the target thread group processes the SSL request.
[0123] According to the technical solution of an embodiment of the present invention, after receiving an SSL request sent by a client, the SSL request can be parsed to determine the type of the SSL request, and then according to the type of the SSL request, a target thread group for executing the SSL request can be determined from a preset thread group, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection, and then the SSL request is allocated to the target thread group so that the target thread group processes the SSL request, thereby improving the efficiency and performance of the communication process.
[0124] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A communication method based on SSL, characterized in that: include: Determine the number of threads in the first thread group according to the number of CPU cores; And according to the number of CPU cores and the network IO throughput, determine the number of threads in the second thread group; Receive SSL request from client; Parsing the SSL request to determine the type of the SSL request; The type of the SSL request includes: an SSL handshake request or an SSL communication request; wherein the SSL handshake request includes: a request to establish an SSL connection with a client, and an outward handshake request indicated by the client; The preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection; according to the type of the SSL request, determining a target thread group for executing the SSL request from the preset thread group, including: when the type indicates that the SSL request is an SSL handshake request, determining the first thread group from the preset thread group as the target thread group for executing the SSL handshake request, including: when the type indicates that the SSL request is a request to establish an SSL connection with a client, establishing an SSL connection with the client through a first thread in the first thread group; when the type indicates that the SSL request is an outward handshake request, sending an SSL handshake request to an external server indicated by the SSL handshake request through a second thread in the first thread group to establish an SSL connection with the external server; when the type indicates that the SSL request is an SSL communication request, determining the second thread group from the preset thread group as the target thread group for executing the SSL communication request; The SSL request is allocated to the target thread group so that the target thread group processes the SSL request.
2. The method according to claim 1, characterized in that After establishing an SSL connection with the external server, the method further includes: Acquire the target certificate of the external server through the SSL connection with the external server; When the target certificate is received, re-issuing the target certificate using a preset local certificate to obtain a new target certificate; The new target certificate is sent to the client through the first thread to establish an SSL connection with the client.
3. The method according to claim 1, characterized in that The parsing of the SSL request to determine the type of the SSL request includes: Parsing the SSL request to obtain header information of the SSL request; The type of the SSL request is determined according to the header information.
4. The method according to claim 1, characterized in that: The allocating the SSL request to the target thread group so that the target thread group processes the SSL request includes: Allocating the SSL request to the target thread group; Selecting a thread in a ready state from among the multiple threads of the target thread group as a target thread; The SSL request is processed by the target thread.
5. A communication device based on SSL, characterized in that: It includes a request receiving module, a parsing module, a thread group determining module, and an allocation module; wherein: The request receiving module is used to determine the number of threads in the first thread group according to the number of CPU cores; and determine the number of threads in the second thread group according to the number of CPU cores and network IO throughput; receive an SSL request sent by a client; the type of the SSL request includes: an SSL handshake request or an SSL communication request; wherein the SSL handshake request includes: a request to establish an SSL connection with the client, and an outward handshake request indicated by the client; The parsing module is used to parse the SSL request and determine the type of the SSL request; The thread group determination module is used to determine, according to the type of the SSL request, a target thread group for executing the SSL request from a preset thread group, wherein the preset thread group includes a first thread group for establishing an SSL connection, and a second thread group for communicating based on the SSL connection; the thread group determination module is also used to, when the type indicates that the SSL request is an SSL handshake request, determine the first thread group from the preset thread group as the target thread group for executing the SSL handshake request, including: when the type indicates that the SSL request is a request to establish an SSL connection with a client, establish an SSL connection with the client through a first thread in the first thread group; when the type indicates that the SSL request is an outward handshake request, send an SSL handshake request to an external server indicated by the SSL handshake request through a second thread in the first thread group to establish an SSL connection with the external server; when the type indicates that the SSL request is an SSL communication request, determine the second thread group from the preset thread group as the target thread group for executing the SSL communication request; The allocation module is used to allocate the SSL request to the target thread group so that the target thread group processes the SSL request.
6. A communication electronic device based on SSL, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
7. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Enhanced thread handling in security handshaking
US20150341386A1
Intercepting, decrypting and inspecting traffic over an encrypted channel
US20160119374A1
