File secure transmission method and system based on HTTPS protocol
By introducing SM2 public and private key negotiation and encryption machine cluster verification into the HTTPS protocol, the problem of insufficient security of HTTP file transmission is solved, effective verification of client identity and file information is achieved, and the security and efficiency of file transmission are improved.
Patent Information
- Application Number
- CN202211510487.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-11-29
AI Technical Summary
Existing file transfer protocols such as HTTP have flaws in security and identity verification. Especially in large file transfer and high-security scenarios, the lack of effective identity authentication and integrity verification mechanisms leads to a high risk of file information leakage.
Using a secure file transmission method based on the HTTPS protocol, through SM2 public and private key negotiation and encryption machine cluster verification, the client encapsulates custom fields in the HTTPS request header for identity information and signature verification, and the server performs legality verification and response processing. Ensure file transfer security.
It effectively solves the high-cost problem of the server verifying the legitimacy of the client's identity during the file transfer process, improves the security of file transfer, reduces the cost of generating HTTPS certificates for each client, and realizes the verification of client identities and files. Validation of legality of information and requested information.
Smart Images

Figure CN116074039B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network information technology, and in particular to a method and system for secure file transmission based on the HTTPS protocol. Background Art
[0002] In the process of informatization construction, file transfer is used in various industries and business scenarios. File transfer refers to transferring a file or part of it from one computer system to another. FTP and HTTP are commonly used file transfer protocols. The full name of HTTP is HyperText Transfer Protocol. HTTP protocol upload is more suitable for WEB applications and small file uploads (within 10M), not suitable for large file uploads, and the security is relatively poor. For example, the communication uses plain text (unencrypted), and the content may be eavesdropped; the identity of the communication party is verified, so it may be disguised; the integrity of the message cannot be proved, so it may have been tampered with. Therefore, it is very important to ensure the security of file transfer.
[0003] Previously, most terminal file transfer methods did not pay enough attention to the security of file transfer. Most of the existing file transfer security mechanisms only encrypt or encode the upgrade files. File transfer only involves the server and the client, lacks a complete identity authentication mechanism, and has no prevention mechanism for file information leakage. Therefore, a complete file transfer method is particularly needed now.
[0004] Patent document CN109428899A (application number: CN201710719512.7) discloses a method and system for managing secure file transmission, which includes: a client and a server communicate and connect; query the server information of the file existing on the server and return it to the client; encrypt and compress the data information of the file according to the client settings and send it to the server; the server decompresses and decrypts the file; the client sends an integrity request, and the server verifies the hash value information of the file after receiving the integrity request and returns it to the client; and judges the integrity of the file transmission. However, the patent document does not verify the legitimacy of the client identity information, file information and request information, and cannot be applied to scenarios with high requirements for file transmission security. Summary of the invention
[0005] In view of the defects in the prior art, the object of the present invention is to provide a method and system for secure file transmission based on the HTTPS protocol.
[0006] A method for secure file transmission based on the HTTPS protocol provided by the present invention includes:
[0007] Step S1: The server and the client negotiate SM2 public and private keys with their respective encryption machine clusters;
[0008] Step S2: The client encapsulates the custom field in the HTTPS request header and sends it to the server;
[0009] Step S3: The server verifies the client request and verifies the legitimacy of the client identity;
[0010] Step S4: The server constructs a file transfer HTTPS response message and sends it to the client;
[0011] Step S5: The client processes the file transfer response.
[0012] Preferably, in step S1:
[0013] Step S1.1: The server and server encryption machine cluster A are deployed in the same intranet, and the client and client encryption machine cluster B are deployed in the same intranet;
[0014] Step S1.2: Importing working keys into encryption machine cluster A and encryption machine cluster B;
[0015] Step S1.3: The server generates a session key and sends it to the encryption machine cluster A. The encryption machine cluster A generates the SM2 public key and private key based on the working key and the session key;
[0016] Step S1.4: The server sends the session key to the client, and the client sends the session key to encryption machine cluster B, which generates the same SM2 public key and private key.
[0017] Preferably, in step S2:
[0018] The client encapsulates custom fields with identity information, file information, request information, and signature information in the HTTPS request header and sends it to the server;
[0019] Step S2.1: The client obtains the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B;
[0020] Step S2.2: Encryption machine cluster B calculates the HASH digest value of the data SrcData according to the SM3 algorithm, then encrypts the digest value using the SM2 private key, generates a digital signature PkgSign and returns it to the client;
[0021] Step S2.3: The client performs Base64 encoding on the digital signature PkgSign, and encapsulates the signature algorithm in the generated data (to increase the scalability of the algorithm), and obtains the signature field value Signature;
[0022] Step S2.4: Add custom header fields to the HTTPS request header, including the USER-ID field (fill in the UserID value), the TIMESTAMP field (fill in the TimeStamp value), the FILE-PATH field (fill in the FilePath value), and the SIGNATURE field (fill in the Signature value);
[0023] Step S2.5: Add the file data in byte stream format to the HTTPS request body, and send the encapsulated HTTPS request to the server.
[0024] Preferably, in step S3:
[0025] Step S3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, the system timestamp TimeStamp, the file storage path FilePath and the digital signature Signature;
[0026] Step S3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If they are illegal, discard the request and record the log.
[0027] Step S3.3: verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A;
[0028] Step S3.4: Encryption machine cluster A calculates the digest HashData of SrcData according to the SM3 algorithm and returns the value to the server;
[0029] Step S3.5: The server performs Base64 decoding on the Signature field of the request header, obtains the decoded data PkgSign and sends it to encryption machine cluster A;
[0030] Step S3.6: Encryption machine cluster A decrypts PkgSign according to the negotiated SM2 public key, obtains the decrypted data PkgData and returns it to the server;
[0031] Step S3.7: The server determines whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, the client identity authentication fails and the request is discarded and a log is recorded.
[0032] Step S3.8: After verification, make different responses according to the request type.
[0033] Preferably, in step S4:
[0034] Step S4.1: Determine the request type and respond differently based on the request type:
[0035] Query class: Add JSON format query information to the request body and return standard HTTPS response information;
[0036] Upload class: writes the request body data to a local directory file and returns a standard HTTPS response message;
[0037] Create and delete classes: perform corresponding file operations and return standard HTTPS response information;
[0038] Download class: execute step S4.2;
[0039] Step S4.2: locally read the file data FileData to be downloaded, and generate the MD5 hash value MD5Data of FileData;
[0040] Step S4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header;
[0041] Step S4.4: Fill the file data into the response body and send it to the client;
[0042] In step S5:
[0043] Step S5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. If successful, execute step S5.2;
[0044] Step S5.2: Determine the response message type. If it is a response message for file download, execute step S5.3; otherwise, record the request as successful and end;
[0045] Step S5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData;
[0046] Step S5.4: read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData;
[0047] Step S5.5: Determine whether the DigestData value is equal to the MD5Data value. If they are equal, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails.
[0048] A file security transmission system based on the HTTPS protocol provided by the present invention includes:
[0049] Module M1: Instruct the server and client to negotiate the SM2 public and private keys with their respective encryption machine clusters;
[0050] Module M2: Instructs the client to encapsulate the custom field in the HTTPS request header and send it to the server;
[0051] Module M3: Instructs the server to verify the client request and verify the legitimacy of the client identity;
[0052] Module M4: Instructs the server to construct a file transfer HTTPS response message and send it to the client;
[0053] Module M5: Instructs the client to process the file transfer response.
[0054] Preferably, in the module M1:
[0055] Module M1.1: The server and server encryption machine cluster A are deployed in the same intranet, and the client and client encryption machine cluster B are deployed in the same intranet;
[0056] Module M1.2: Import the working key into encryption machine cluster A and encryption machine cluster B;
[0057] Module M1.3: instructs the server to generate a session key and send it to encryption machine cluster A. Encryption machine cluster A generates SM2 public key and private key based on the working key and session key.
[0058] Module M1.4: Instruct the server to send the session key to the client, and the client sends the session key to the encryption machine cluster B, which generates the same SM2 public key and private key.
[0059] Preferably, in the module M2:
[0060] Instruct the client to encapsulate custom fields with identity information, file information, request information, and signature information in the HTTPS request header and send it to the server;
[0061] Module M2.1: Instructs the client to obtain the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B;
[0062] Module M2.2: Instruct the encryption machine cluster B to calculate the HASH summary value of the data SrcData according to the SM3 algorithm, and then encrypt the summary value using the SM2 private key, generate a digital signature PkgSign and return it to the client;
[0063] Module M2.3: Instruct the client to perform Base64 encoding on the digital signature PkgSign, encapsulate the signature algorithm in the generated data (to increase the scalability of the algorithm), and obtain the signature field value Signature;
[0064] Module M2.4: Add custom header fields to the HTTPS request header, including the USER-ID field (fill in the UserID value), TIMESTAMP field (fill in the TimeStamp value), FILE-PATH field (fill in the FilePath value), and SIGNATURE field (fill in the Signature value);
[0065] Module M2.5: Add file data in byte stream format to the HTTPS request body and send the encapsulated HTTPS request to the server.
[0066] Preferably, in the module M3:
[0067] Module M3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, the system timestamp TimeStamp, the file storage path FilePath and the digital signature Signature;
[0068] Module M3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If they are illegal, discard the request and record the log.
[0069] Module M3.3: Verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A;
[0070] Module M3.4: Instruct the encryption machine cluster A to calculate the digest HashData of SrcData according to the SM3 algorithm and return the value to the server;
[0071] Module M3.5: Instruct the server to perform Base64 decoding on the Signature field in the request header, obtain the decoded data PkgSign and send it to encryption machine cluster A;
[0072] Module M3.6: Instruct the encryption machine cluster A to decrypt PkgSign according to the negotiated SM2 public key, obtain the decrypted data PkgData and return it to the server;
[0073] Module M3.7: Instruct the server to determine whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, it fails, the request is discarded, and a log is recorded.
[0074] Module M3.8: After verification, respond differently based on the request type.
[0075] Preferably, in the module M4:
[0076] Module M4.1: Determine the request type and respond differently based on the request type:
[0077] Query class: Add JSON format query information to the request body and return standard HTTPS response information;
[0078] Upload class: writes the request body data to a local directory file and returns a standard HTTPS response message;
[0079] Create and delete classes: perform corresponding file operations and return standard HTTPS response information;
[0080] Download class: Execution module M4.2;
[0081] Module M4.2: locally read the file data FileData to be downloaded, and generate the MD5 hash value MD5Data of FileData;
[0082] Module M4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header;
[0083] Module M4.4: Fill the file data into the response body and send it to the client;
[0084] In the module M5:
[0085] Module M5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. Module M5.2 is executed successfully;
[0086] Module M5.2: Determine the response message type. If it is a response message for file download, execute module M5.3; otherwise, record the request as successful and end;
[0087] Module M5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData;
[0088] Module M5.4: read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData;
[0089] Module M5.5: Determine whether the DigestData value is equal to the MD5Data value. If so, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails.
[0090] Compared with the prior art, the present invention has the following beneficial effects:
[0091] 1. The present invention solves the high cost problem of the server verifying the legitimacy of the client identity during the file transfer process;
[0092] 2. The present invention adds a custom digital signature field to the HTTPS standard message header, and fills in the digital signature value generated by the encryption machine. The server completes the identity authentication of the client, thereby solving the high cost problem of generating an HTTPS certificate for each client during the file transfer process.
[0093] 3. The present invention preprocesses the client identity information, file information and request information, and sends the preprocessed information to the encryption machine cluster. The encryption machine cluster uses the preprocessed information to generate a digital signature and returns it to the client. The client sends the file to the server through the HTTPS protocol in combination with the digital signature based on the scalability of the HTTPS standard message header. The server completes the digital signature verification through the encryption machine, realizes the legitimacy verification of the client identity by the server, and improves security. BRIEF DESCRIPTION OF THE DRAWINGS
[0094] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0095] Figure 1 This is the HTTPS request message structure;
[0096] Figure 2It is the HTTPS response message structure;
[0097] Figure 3 It is the basic network diagram of the system;
[0098] Figure 4 Construct a process for HTTPS request messages;
[0099] Figure 5 It is the HTTPS authentication process;
[0100] Figure 6 This is the HTTPS message response process;
[0101] Figure 7 This is the file integrity verification process. DETAILED DESCRIPTION
[0102] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0103] Embodiment 1:
[0104] When the client sends a file to the server, the client identity information, file information and request information are preprocessed, and the preprocessed information is sent to the encryption machine cluster. The encryption machine cluster uses the preprocessed information to generate a digital signature and returns it to the client. The client sends the file to the server through the HTTPS protocol based on the extensibility of the HTTPS standard message header and the digital signature. The server completes the digital signature verification through the encryption machine, realizes the server's legitimacy verification of the client's identity, and solves the high cost problem of the server verifying the legitimacy of the client's identity during the file transfer process.
[0105] By adding a custom digital signature field to the HTTPS standard message header and filling in the digital signature value generated by the encryption machine, the server completes the identity authentication of the client, thus solving the high cost problem of generating HTTPS certificates for each client during the file transfer process.
[0106] According to a method for secure file transmission based on HTTPS protocol provided by the present invention, Figure 1-Figure 6 As shown, including:
[0107] Step S1: The server and the client negotiate SM2 public and private keys with their respective encryption machine clusters;
[0108] Specifically, in step S1:
[0109] Step S1.1: The server and server encryption machine cluster A are deployed in the same intranet, and the client and client encryption machine cluster B are deployed in the same intranet;
[0110] Step S1.2: Importing working keys into encryption machine cluster A and encryption machine cluster B;
[0111] Step S1.3: The server generates a session key and sends it to the encryption machine cluster A. The encryption machine cluster A generates the SM2 public key and private key based on the working key and the session key;
[0112] Step S1.4: The server sends the session key to the client, and the client sends the session key to encryption machine cluster B, which generates the same SM2 public key and private key.
[0113] Step S2: The client encapsulates the custom field in the HTTPS request header and sends it to the server;
[0114] Specifically, in step S2:
[0115] The client encapsulates custom fields with identity information, file information, request information, and signature information in the HTTPS request header and sends it to the server;
[0116] Step S2.1: The client obtains the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B;
[0117] Step S2.2: Encryption machine cluster B calculates the HASH digest value of the data SrcData according to the SM3 algorithm, then encrypts the digest value using the SM2 private key, generates a digital signature PkgSign and returns it to the client;
[0118] Step S2.3: The client performs Base64 encoding on the digital signature PkgSign, and encapsulates the signature algorithm in the generated data (to increase the scalability of the algorithm), and obtains the signature field value Signature;
[0119] Step S2.4: Add custom header fields to the HTTPS request header, including the USER-ID field (fill in the UserID value), the TIMESTAMP field (fill in the TimeStamp value), the FILE-PATH field (fill in the FilePath value), and the SIGNATURE field (fill in the Signature value);
[0120] Step S2.5: Add the file data in byte stream format to the HTTPS request body, and send the encapsulated HTTPS request to the server.
[0121] Step S3: The server verifies the client request and verifies the legitimacy of the client identity;
[0122] Specifically, in step S3:
[0123] Step S3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, the system timestamp TimeStamp, the file storage path FilePath and the digital signature Signature;
[0124] Step S3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If they are illegal, discard the request and record the log.
[0125] Step S3.3: verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A;
[0126] Step S3.4: Encryption machine cluster A calculates the digest HashData of SrcData according to the SM3 algorithm and returns the value to the server;
[0127] Step S3.5: The server performs Base64 decoding on the Signature field of the request header, obtains the decoded data PkgSign and sends it to encryption machine cluster A;
[0128] Step S3.6: Encryption machine cluster A decrypts PkgSign according to the negotiated SM2 public key, obtains the decrypted data PkgData and returns it to the server;
[0129] Step S3.7: The server determines whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, the client identity authentication fails and the request is discarded and a log is recorded.
[0130] Step S3.8: After verification, make different responses according to the request type.
[0131] Step S4: The server constructs a file transfer HTTPS response message and sends it to the client;
[0132] Specifically, in step S4:
[0133] Step S4.1: Determine the request type and respond differently based on the request type:
[0134] Query class: add query information in json format to the body and return standard HTTPS response information;
[0135] Upload class: writes body data to a local directory file and returns standard HTTPS response information;
[0136] Create and delete classes: perform corresponding file operations and return standard HTTPS response information;
[0137] Download class: execute step S4.2;
[0138] Step S4.2: locally read the file data FileData to be downloaded, and generate the MD5 hash value MD5Data of FileData;
[0139] Step S4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header;
[0140] Step S4.4: Fill the file data into the response body and send it to the client;
[0141] Step S5: The client processes the file transfer response.
[0142] In step S5:
[0143] Step S5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. If successful, execute step S5.2;
[0144] Step S5.2: Determine the response message type. If it is a response message for file download, execute step S5.3; otherwise, record the request as successful and end;
[0145] Step S5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData;
[0146] Step S5.4: read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData;
[0147] Step S5.5: Determine whether the DigestData value is equal to the MD5Data value. If they are equal, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails.
[0148] Embodiment 2:
[0149] Embodiment 2 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0150] The present invention also provides a file security transmission system based on the HTTPS protocol. The file security transmission system based on the HTTPS protocol can be implemented by executing the process steps of the file security transmission method based on the HTTPS protocol, that is, those skilled in the art can understand the file security transmission method based on the HTTPS protocol as a preferred implementation of the file security transmission system based on the HTTPS protocol.
[0151] A file security transmission system based on the HTTPS protocol provided by the present invention includes:
[0152] Module M1: Instruct the server and client to negotiate the SM2 public and private keys with their respective encryption machine clusters;
[0153] Specifically, in the module M1:
[0154] Module M1.1: The server and server encryption machine cluster A are deployed in the same intranet, and the client and client encryption machine cluster B are deployed in the same intranet;
[0155] Module M1.2: Import the working key into encryption machine cluster A and encryption machine cluster B;
[0156] Module M1.3: instructs the server to generate a session key and send it to encryption machine cluster A. Encryption machine cluster A generates SM2 public key and private key based on the working key and session key.
[0157] Module M1.4: Instruct the server to send the session key to the client, and the client sends the session key to the encryption machine cluster B, which generates the same SM2 public key and private key.
[0158] Module M2: Instructs the client to encapsulate the custom field in the HTTPS request header and send it to the server;
[0159] Specifically, in the module M2:
[0160] Instruct the client to encapsulate custom fields with identity information, file information, request information, and signature information in the HTTPS request header and send it to the server;
[0161] Module M2.1: Instructs the client to obtain the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B;
[0162] Module M2.2: Instruct the encryption machine cluster B to calculate the HASH summary value of the data SrcData according to the SM3 algorithm, and then encrypt the summary value using the SM2 private key, generate a digital signature PkgSign and return it to the client;
[0163] Module M2.3: Instruct the client to perform Base64 encoding on the digital signature PkgSign, encapsulate the signature algorithm in the generated data (to increase the scalability of the algorithm), and obtain the signature field value Signature;
[0164] Module M2.4: Add custom header fields to the HTTPS request header, including the USER-ID field (fill in the UserID value), TIMESTAMP field (fill in the TimeStamp value), FILE-PATH field (fill in the FilePath value), and SIGNATURE field (fill in the Signature value);
[0165] Module M2.5: Add file data in byte stream format to the HTTPS request body and send the encapsulated HTTPS request to the server.
[0166] Module M3: Instructs the server to verify the client request and verify the legitimacy of the client identity;
[0167] Specifically, in the module M3:
[0168] Module M3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, the system timestamp TimeStamp, the file storage path FilePath and the digital signature Signature;
[0169] Module M3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If they are illegal, discard the request and record the log.
[0170] Module M3.3: Verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A;
[0171] Module M3.4: Instruct the encryption machine cluster A to calculate the digest HashData of SrcData according to the SM3 algorithm and return the value to the server;
[0172] Module M3.5: Instruct the server to perform Base64 decoding on the Signature field in the request header, obtain the decoded data PkgSign and send it to encryption machine cluster A;
[0173] Module M3.6: Instruct the encryption machine cluster A to decrypt PkgSign according to the negotiated SM2 public key, obtain the decrypted data PkgData and return it to the server;
[0174] Module M3.7: Instruct the server to determine whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, it fails, the request is discarded, and a log is recorded.
[0175] Module M3.8: After verification, respond differently based on the request type.
[0176] Module M4: Instructs the server to construct a file transfer HTTPS response message and send it to the client;
[0177] Specifically, in the module M4:
[0178] Module M4.1: Determine the request type and respond differently based on the request type:
[0179] Query class: add query information in json format to the body and return standard HTTPS response information;
[0180] Upload class: writes body data to a local directory file and returns standard HTTPS response information;
[0181] Create and delete classes: perform corresponding file operations and return standard HTTPS response information;
[0182] Download class: Execution module M4.2;
[0183] Module M4.2: locally read the file data FileData to be downloaded, and generate the MD5 hash value MD5Data of FileData;
[0184] Module M4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header;
[0185] Module M4.4: Fill the file data into the response body and send it to the client;
[0186] Module M5: Instructs the client to process the file transfer response.
[0187] In the module M5:
[0188] Module M5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. Module M5.2 is executed successfully;
[0189] Module M5.2: Determine the response message type. If it is a response message for file download, execute module M5.3; otherwise, record the request as successful and end;
[0190] Module M5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData;
[0191] Module M5.4: read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData;
[0192] Module M5.5: Determine whether the DigestData value is equal to the MD5Data value. If so, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails.
[0193] Embodiment 3:
[0194] Embodiment 3 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0195] Step 1: The server encryption machine cluster A and the client encryption machine cluster B negotiate the SM2 public and private keys;
[0196] Step 2: The client encapsulates the custom fields with identity information, file information, request information, and signature information in the HTTPS request header and sends it to the server;
[0197] Step 3: The server verifies the client request and the signature to verify the client's identity;
[0198] Step 4: The server constructs a file transfer HTTPS response message and sends it to the client;
[0199] Step 5: The client processes the file transfer response.
[0200] Step 1 includes the following steps:
[0201] Step 1.1: The server and encryption machine cluster A are in the same intranet, and the client and encryption machine cluster B are in the same intranet (refer to system deployment Figure 3 );
[0202] Step 1.2: Import the working key into encryption machine cluster A and encryption machine cluster B;
[0203] Step 1.3: The server generates a session key and sends it to encryption machine cluster A. Encryption machine cluster A generates SM2 public key and private key based on the working key and session key;
[0204] Step 1.4: The server sends the session key to the client, and the client sends the session key to the encryption machine cluster B. The encryption machine cluster B generates the same SM2 public key and private key;
[0205] Step 1.5: End.
[0206] Step 2 includes the following steps (refer to the process Figure 4 ):
[0207] Step 2.1: The client obtains the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B;
[0208] Step 2.2: Encryption machine cluster B calculates the HASH digest value of SrcData according to the SM3 algorithm, then encrypts the digest value using the SM2 private key, generates a digital signature PkgSign and returns it to the client;
[0209] Step 2.3: The client performs Base64 encoding on the digital signature PkgSign and encapsulates the signature algorithm in the generated data (to increase the scalability of the algorithm) to obtain the final signature field value Signature;
[0210] Step 2.4: Reference Figure 1 , add custom header fields in the HTTPS request header, including the USER-ID field (fill in the UserID value), TIMESTAMP field (fill in the TimeStamp value), FILE-PATH field (fill in the FilePath value) and SIGNATURE field (fill in the Signature value);
[0211] Step 2.5: Add the file data in byte stream format to the HTTPS request body and send the encapsulated HTTPS request to the server.
[0212] Step 3 includes the following steps (refer to the process Figure 5 ):
[0213] Step 3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, system timestamp TimeStamp, file storage path FilePath and digital signature Signature;
[0214] Step 3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If not, discard the request and record the log.
[0215] Step 3.3: Verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A;
[0216] Step 3.4: Encryption machine cluster A calculates the digest HashData of SrcData according to the SM3 algorithm and returns the value to the server;
[0217] Step 3.5: The server decodes the Signature field in the request header with Base64, obtains the decoded data PkgSign and sends it to encryption machine cluster A;
[0218] Step 3.6: Encryption machine cluster A decrypts PkgSign according to the negotiated SM2 public key, obtains the decrypted data PkgData and returns it to the server;
[0219] Step 3.7: The server determines whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, it fails, the request is discarded, and a log is recorded.
[0220] Step 3.8: After verification, respond differently according to the request type (see step 4 for details) and end.
[0221] Step 4 includes the following steps (refer to the process Figure 6 ):
[0222] Step 4.1: Determine the request type and respond differently according to the request type (query class: add json format query information in the body and return standard HTTPS response information; upload class: write body data to the local directory file and return standard HTTPS response information; download class: execute step 4.2); create and delete class: perform corresponding file operations and then return standard HTTPS response information);
[0223] Step 4.2: Read the file data FileData to be downloaded locally and generate the MD5 hash value MD5Data of FileData;
[0224] Step 4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header (refer to Figure 2);
[0225] Step 4.4: Fill the file data into the response body and send it to the client;
[0226] Step 4.5: End.
[0227] Step 5 includes the following steps (refer to the flow chart Figure 7 ):
[0228] Step 5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. If successful, proceed to step 5.2;
[0229] Step 5.2: Determine the response message type. If it is a response message for file download, execute step 5.3. Otherwise, record the request as successful and end.
[0230] Step 5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData;
[0231] Step 5.4: Read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData;
[0232] Step 5.5: Determine whether the DigestData value is equal to the MD5Data value. If so, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails;
[0233] Step 5.6: End.
[0234] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.
[0235] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A method for secure file transmission based on HTTPS protocol, characterized in that: include: Step S1: The server and the client negotiate SM2 public and private keys with their respective encryption machine clusters; Step S2: The client encapsulates the custom field in the HTTPS request header and sends it to the server; Step S3: The server verifies the client request and verifies the legitimacy of the client identity; Step S4: The server constructs a file transfer HTTPS response message and sends it to the client; Step S5: The client processes the file transfer response; In step S2: The client encapsulates custom fields with identity information, file information, request information, and signature information in the HTTPS request header and sends it to the server; Step S2.1: The client obtains the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B; Step S2.2: Encryption machine cluster B calculates the HASH digest value of the data SrcData according to the SM3 algorithm, then encrypts the digest value using the SM2 private key, generates a digital signature PkgSign and returns it to the client; Step S2.3: The client performs Base64 encoding on the digital signature PkgSign, encapsulates the signature algorithm in the generated data, and obtains the signature field value Signature; Step S2.4: Add custom header fields to the HTTPS request header, including the USER-ID field, TIMESTAMP field, FILE-PATH field, and SIGNATURE field; Step S2.5: Add the file data in byte stream format to the HTTPS request body, and send the encapsulated HTTPS request to the server.
2. The method for secure file transmission based on the HTTPS protocol according to claim 1, characterized in that: In step S1: Step S1.1: The server and server encryption machine cluster A are deployed in the same intranet, and the client and client encryption machine cluster B are deployed in the same intranet; Step S1.2: Importing working keys into encryption machine cluster A and encryption machine cluster B; Step S1.3: The server generates a session key and sends it to the encryption machine cluster A. The encryption machine cluster A generates the SM2 public key and private key based on the working key and the session key; Step S1.4: The server sends the session key to the client, and the client sends the session key to encryption machine cluster B, which generates the same SM2 public key and private key.
3. The secure file transmission method based on the HTTPS protocol according to claim 1, characterized in that: In step S3: Step S3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, the system timestamp TimeStamp, the file storage path FilePath and the digital signature Signature; Step S3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If they are illegal, discard the request and record the log. Step S3.3: verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A; Step S3.4: Encryption machine cluster A calculates the digest HashData of SrcData according to the SM3 algorithm and returns the value to the server; Step S3.5: The server performs Base64 decoding on the Signature field of the request header, obtains the decoded data PkgSign and sends it to encryption machine cluster A; Step S3.6: Encryption machine cluster A decrypts PkgSign according to the negotiated SM2 public key, obtains the decrypted data PkgData and returns it to the server; Step S3.7: The server determines whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, the client identity authentication fails and the request is discarded and a log is recorded. Step S3.8: After verification, make different responses according to the request type.
4. The method for secure file transmission based on the HTTPS protocol according to claim 1, characterized in that: In step S4: Step S4.1: Determine the request type and respond differently based on the request type: Query class: Add JSON format query information to the request body and return standard HTTPS response information; Upload class: writes the request body data to a local directory file and returns a standard HTTPS response message; Create and delete classes: perform corresponding file operations and return standard HTTPS response information; Download class: execute step S4.2; Step S4.2: locally read the file data FileData to be downloaded, and generate the MD5 hash value MD5Data of FileData; Step S4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header; Step S4.4: Fill the file data into the response body and send it to the client; In step S5: Step S5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. If successful, execute step S5.2; Step S5.2: Determine the response message type. If it is a response message for file download, execute step S5.3; otherwise, record the request as successful and end; Step S5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData; Step S5.4: read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData; Step S5.5: Determine whether the DigestData value is equal to the MD5Data value. If they are equal, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails.
5. A file security transmission system based on HTTPS protocol, characterized in that: include: Module M1: Instruct the server and client to negotiate the SM2 public and private keys with their respective encryption machine clusters; Module M2: Instructs the client to encapsulate the custom field in the HTTPS request header and send it to the server; Module M3: Instructs the server to verify the client request and verify the legitimacy of the client identity; Module M4: Instructs the server to construct a file transfer HTTPS response message and send it to the client; Module M5: Instruct the client to process the file transfer response; In the module M2: Instruct the client to encapsulate custom fields with identity information, file information, request information, and signature information in the HTTPS request header and send it to the server; Module M2.1: Instructs the client to obtain the original data including the request line RequestLine, the user code UserID, the system timestamp TimeStamp and the file storage path FilePath, and sends the pre-processed data SrcData to the encryption machine cluster B; Module M2.2: Instruct the encryption machine cluster B to calculate the HASH summary value of the data SrcData according to the SM3 algorithm, and then encrypt the summary value using the SM2 private key, generate a digital signature PkgSign and return it to the client; Module M2.3: Instruct the client to perform Base64 encoding on the digital signature PkgSign, encapsulate the signature algorithm in the generated data, and obtain the signature field value Signature; Module M2.4: Add custom header fields to the HTTPS request header, including the USER-ID field, TIMESTAMP field, FILE-PATH field, and SIGNATURE field; Module M2.5: Add file data in byte stream format to the HTTPS request body and send the encapsulated HTTPS request to the server.
6. The secure file transmission system based on the HTTPS protocol according to claim 5, characterized in that: In the module M1: Module M1.1: The server and server encryption machine cluster A are deployed in the same intranet, and the client and client encryption machine cluster B are deployed in the same intranet; Module M1.2: Import the working key into encryption machine cluster A and encryption machine cluster B; Module M1.3: instructs the server to generate a session key and send it to encryption machine cluster A. Encryption machine cluster A generates SM2 public key and private key based on the working key and session key. Module M1.4: Instruct the server to send the session key to the client, and the client sends the session key to the encryption machine cluster B, which generates the same SM2 public key and private key.
7. The secure file transmission system based on the HTTPS protocol according to claim 5, characterized in that: In the module M3: Module M3.1: After receiving the HTTPS request, the server parses the message to obtain the request line RequestLine and the newly added header fields in the request header, including the user ID UserID, the system timestamp TimeStamp, the file storage path FilePath and the digital signature Signature; Module M3.2: Verify whether the request method, UserID, TimeStamp, and FilePath in RequestLine are legal. If they are illegal, discard the request and record the log. Module M3.3: Verify the file signature, pre-process the original data of RequestLine, UserID, TimeStamp and FilePath, and send the pre-processed data SrcData to the encryption machine cluster A; Module M3.4: Instruct the encryption machine cluster A to calculate the digest HashData of SrcData according to the SM3 algorithm and return the value to the server; Module M3.5: Instruct the server to perform Base64 decoding on the Signature field in the request header, obtain the decoded data PkgSign and send it to encryption machine cluster A; Module M3.6: Instruct the encryption machine cluster A to decrypt PkgSign according to the negotiated SM2 public key, obtain the decrypted data PkgData and return it to the server; Module M3.7: Instruct the server to determine whether the digest value HashData is equal to PkgData. If so, the client identity authentication is successful. Otherwise, it fails, the request is discarded, and a log is recorded. Module M3.8: After verification, respond differently based on the request type.
8. The secure file transmission system based on the HTTPS protocol according to claim 5, characterized in that: In the module M4: Module M4.1: Determine the request type and respond differently based on the request type: Query class: Add JSON format query information to the request body and return standard HTTPS response information; Upload class: writes the request body data to a local directory file and returns a standard HTTPS response message; Create and delete classes: perform corresponding file operations and return standard HTTPS response information; Download class: Execution module M4.2; Module M4.2: locally read the file data FileData to be downloaded, and generate the MD5 hash value MD5Data of FileData; Module M4.3: Base16 encode the hash value MD5Data and fill the encoded value into the custom header field DIGESET in the response header; Module M4.4: Fill the file data into the response body and send it to the client; In the module M5: Module M5.1: Receive and parse the HTTPS response message, determine whether the response result is successful, and exit and record the log if it fails. Module M5.2 is executed successfully; Module M5.2: Determine the response message type. If it is a response message for file download, execute module M5.3; otherwise, record the request as successful and end; Module M5.3: Get the value of the custom header field DIGESET in the response header, and perform Base16 decoding on the DIGESET value to obtain the data DigestData; Module M5.4: read the file data FileData in the response body, and calculate the MD5 hash value MD5Data of FileData; Module M5.5: Determine whether the DigestData value is equal to the MD5Data value. If so, the integrity verification of the downloaded file passes and the file is saved; otherwise, the verification fails.
