A method and system for automatic repair of digital certificates

By automatically applying validity verification and repair rules to the digital certificates of vehicle-to-everything (V2X) terminals, the problem of format errors when certificate parsing fails is solved, thus improving production line efficiency and certificate recovery efficiency.

CN123184844APending Publication Date: 2026-11-27NINGBO JOYNEXT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611170324.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-04
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

When the vehicle-to-everything (V2X) terminal fails to parse the digital certificate, it cannot automatically identify and repair format errors in the certificate data, resulting in reduced production line efficiency.

Method used

An automatic repair method for digital certificates is provided. The method identifies repairable anomalies through validity verification, executes the corresponding repair rules, and performs further verification and continuous repair on candidate certificate data, including start mark repair, end mark repair, certificate encoding repair, and line break format repair, until the certificate data conforms to the preset encapsulation format.

Benefits of technology

It enables automatic diagnosis and repair of digital certificates, reducing re-injection and manual processing, and improving the certificate recovery efficiency and repair success rate of vehicle networking terminals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123184844A_ABST
    Figure CN123184844A_ABST
Patent Text Reader

Abstract

The application provides an automatic repairing method and system of a digital certificate, and the automatic repairing method comprises the following steps: obtaining certificate data to be processed of a terminal of Internet of Vehicles; judging whether the certificate data to be processed can pass validity verification; if the certificate data to be processed cannot pass the validity verification, determining a repairable abnormality existing in the certificate data to be processed according to a verification result of the validity verification; repairing the certificate data to be processed according to a repair rule corresponding to the repairable abnormality to obtain candidate certificate data, and judging whether the candidate certificate data can pass the validity verification; if the candidate certificate data cannot pass the validity verification, judging whether there is a repair rule that has not been executed; if yes, executing the repair rule that has not been executed on the candidate certificate data and then performing the validity verification again. The application solves the technical problem that in the prior art, when the terminal of Internet of Vehicles fails in digital certificate analysis, the terminal cannot automatically identify and repair format errors in the certificate data, thereby reducing the production line efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of digital certificate refilling technology, and more specifically, to an automatic repair method and system for digital certificates. Background Technology

[0002] Vehicle-to-everything (V2X) terminals are typically equipped with digital certificates to enable authentication and secure communication between vehicles, in-vehicle terminals, and external devices. Digital certificates can be written during the terminal production phase via certificate injection devices, or they can be updated remotely during terminal operation.

[0003] During the transmission, injection, update, or storage of digital certificates, factors such as transmission anomalies, system differences, or data processing errors may cause certificate data to be formatted incorrectly, preventing vehicle-to-everything (V2X) terminals from properly parsing and using the digital certificate. Current processing methods typically determine an invalid certificate upon detection of anomalies and restore it through re-acquisition, re-injection, or manual processing. This lack of a mechanism for automatically identifying anomalies based on verification results and performing corresponding repairs results in long processing cycles, high maintenance costs, and disruptions to normal terminal authentication and communication.

[0004] However, the relevant technologies have at least one of the following problems: In the existing technology, when the vehicle networking terminal fails to parse the digital certificate, it cannot automatically identify and repair the format errors in the certificate data, which leads to a reduction in production line efficiency. Summary of the Invention

[0005] The technical problem solved by this invention is that in the prior art, when the vehicle networking terminal fails to parse the digital certificate, it cannot automatically identify and repair the format errors in the certificate data, which leads to a reduction in production line efficiency.

[0006] To address the aforementioned issues, this invention provides an automatic repair method for digital certificates. The automatic repair method includes: acquiring certificate data to be processed from a vehicle-to-everything (V2X) terminal; determining whether the certificate data can pass a validity check; if it passes the validity check, determining the certificate data to be processed as valid certificate data; if it fails the validity check, identifying repairable anomalies in the certificate data to be processed based on the validity check result; repairing the certificate data to be processed according to the repair rules corresponding to the repairable anomalies to obtain candidate certificate data, and determining whether the candidate certificate data can pass a validity check; if it passes the validity check, determining the candidate certificate data as valid certificate data; if it fails the validity check, determining whether there are any unexecuted repair rules; if so, executing the unexecuted repair rules on the candidate certificate data and then re-performing the validity check; if not, determining the candidate certificate data as unrepairable certificate data; and sending the determination result of the certificate data to be processed or the candidate certificate data to the V2X terminal.

[0007] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: by validating the certificate data to be processed, identifying repairable anomalies and executing corresponding repair rules when the verification fails, and simultaneously re-verifying and continuously repairing candidate certificate data, automatic diagnosis, automatic repair, and repair result determination of digital certificates are realized, reducing certificate re-injection and manual processing, and improving the certificate recovery efficiency of vehicle networking terminals.

[0008] In one embodiment of the present invention, determining the repairable anomalies in the certificate data to be processed based on the validity verification result includes: obtaining anomaly information generated by the validity verification, the anomaly information including error codes and / or error strings; extracting anomaly identifiers from the anomaly information, and determining the anomaly type of the repairable anomaly based on the correspondence between the anomaly identifiers and preset anomaly types; and / or performing a format scan on the certificate data to be processed, and determining the anomaly type of the repairable anomaly based on the data structure characteristics obtained from the scan.

[0009] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: by combining the error codes, error strings generated by validity verification and the format scanning results of certificate data to determine the anomaly type, the accuracy of identifying repairable anomalies is improved, enabling the system to call the corresponding repair rules for different anomalies.

[0010] In one embodiment of the present invention, the repairable anomalies include at least one of the following: start mark anomaly, end mark anomaly, certificate encoding anomaly, and line break format anomaly; the repair rules include at least one of the following: start mark repair corresponding to start mark anomaly, end mark repair corresponding to end mark anomaly, certificate encoding repair corresponding to certificate encoding anomaly, and line break format repair corresponding to line break format anomaly.

[0011] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: by classifying repairable anomalies into start mark anomalies, end mark anomalies, certificate encoding anomalies, and line break format anomalies, and configuring corresponding repair rules for each, the range of automatically repairable anomaly types is expanded, and the applicability of automatic digital certificate repair is improved.

[0012] In one embodiment of the present invention, the starting mark repair includes: locating a first boundary row containing a first boundary mark in the certificate data to be processed or candidate certificate data; determining whether certificate type information can be extracted from the first boundary row; if certificate type information can be extracted, determining the extracted certificate type information as the first target type information; if certificate type information cannot be extracted, determining the preset certificate type information as the first target type information; correcting the first boundary row to conform to the preset certificate encapsulation format according to the first target type information; and deleting additional data located before the first boundary row.

[0013] Compared with existing technologies, the technical effects achieved by this technical solution are as follows: by determining the certificate type information in the first boundary line, correcting the first boundary line and deleting the additional data in front of it, the certificate data has an initial structure that conforms to the preset encapsulation format, thus avoiding certificate parsing failure caused by abnormal first boundary markers or preceding interference data.

[0014] In one embodiment of the present invention, tail mark repair includes: locating a second boundary row containing a second boundary mark in the certificate data to be processed or candidate certificate data; determining whether certificate type information can be extracted from the second boundary row; if certificate type information can be extracted, determining the extracted certificate type information as the second target type information; if certificate type information cannot be extracted, determining the preset certificate type information as the second target type information; correcting the second boundary row to a boundary row conforming to the preset certificate encapsulation format according to the second target type information; and deleting the additional data located after the second boundary row.

[0015] Compared with existing technologies, the technical effects achieved by this technical solution are as follows: by determining the certificate type information in the second boundary line, correcting the second boundary line and deleting the additional data after it, the certificate data has an ending structure that conforms to the preset encapsulation format, thus avoiding certificate parsing failure caused by abnormal first boundary markers or trailing interference data.

[0016] In one embodiment of the present invention, certificate encoding repair includes: extracting certificate encoding data from certificate data to be processed or candidate certificate data; retaining valid encoded characters and removing invalid encoded characters from the certificate encoding data according to a preset set of valid characters; and reorganizing the retained valid encoded characters according to a preset data organization rule.

[0017] Compared with existing technologies, the technical effects achieved by this solution are as follows: by retaining valid encoded characters in the certificate encoded data, removing invalid encoded characters, and reorganizing valid encoded characters, the valid format of the certificate encoded data is restored, thereby improving the success rate of repairing certificates that fail to be parsed due to the inclusion of abnormal characters in the encoded data.

[0018] In one embodiment of the present invention, line break format repair includes: converting non-target line breaks in the certificate data to be processed or candidate certificate data into target line breaks; deleting redundant blank lines in the certificate data to be processed or candidate certificate data; setting the line spacing and file end position of the certificate data to be processed or candidate certificate data according to preset line break rules; wherein, in the case that the repairable anomaly includes at least one of start mark anomaly and certificate encoding anomaly, line break format repair is performed first, and then the repair corresponding to each of the identified repairable anomalies is performed.

[0019] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: by unifying the line breaks in the certificate data, deleting redundant blank lines, and adjusting the line spacing and file end position, the impact of different line break formats on certificate parsing is eliminated; at the same time, performing line break format repair before starting mark repair or certificate encoding repair can provide certificate data with a unified format for subsequent repairs, thereby improving the reliability of subsequent repairs.

[0020] In one embodiment of the present invention, the preset execution order of the repair rules is as follows: newline format repair, start mark repair, end mark repair, and certificate encoding repair.

[0021] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: by executing the repair rules in the order of line break format repair, start mark repair, end mark repair and certificate encoding repair, the mutual interference between different repair operations is reduced, and multiple anomalies can be repaired step by step in the order from basic format to encoded content, thereby improving the repair efficiency and success rate of multi-anomaly certificates.

[0022] In one embodiment of the present invention, sending the determination result of the certificate data to be processed or the candidate certificate data to the vehicle network terminal includes: if the certificate data to be processed or the candidate certificate data is determined to be valid certificate data, then the certificate data to be processed or the candidate certificate data is written into the certificate storage area of ​​the vehicle network terminal, and the repairable anomaly corresponding to this repair, the repair rule executed, and the repair time are recorded; if the certificate data to be processed or the candidate certificate data is determined to be unrepairable certificate data, then a manual repair request is sent to the vehicle network terminal.

[0023] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: by writing the certificate data determined to be valid into the certificate storage area of ​​the vehicle network terminal and recording the anomaly type, repair rules and repair time, the practical application of the repair results and the traceability of the repair process are realized; when the certificate cannot be repaired, a manual repair request is sent to facilitate timely follow-up processing.

[0024] On the other hand, the present invention also provides an automatic repair system for digital certificates, comprising: a certificate acquisition module for acquiring certificate data to be processed from a vehicle network terminal; a verification module for determining whether the certificate data to be processed can pass validity verification; an anomaly determination module for determining, based on the validity verification result, repairable anomalies in the certificate data to be processed if the certificate data to be processed fails validity verification; a repair module for repairing the certificate data to be processed according to repair rules corresponding to repairable anomalies to obtain candidate certificate data; the verification module is also used to determine whether the candidate certificate data can pass validity verification; a rule judgment module for determining whether there are any unexecuted repair rules if the candidate certificate data fails validity verification; and a repair module... The module is also used to execute unexecuted repair rules on candidate certificate data if there are unexecuted repair rules; the verification module is also used to re-verify the validity of candidate certificate data after the repair module executes the unexecuted repair rules on candidate certificate data; the certificate determination module is used to determine the certificate data to be processed as valid certificate data if the certificate data to be processed passes the validity verification, to determine the candidate certificate data as valid certificate data if the candidate certificate data passes the validity verification, and to determine the candidate certificate data as unrepairable certificate data if the candidate certificate data fails the validity verification and there are no unexecuted repair rules; the result sending module is used to send the determination result of the certificate data to be processed or the candidate certificate data to the vehicle network terminal.

[0025] Compared with existing technologies, the technical effects achieved by adopting this technical solution are as follows: it can achieve the technical effects corresponding to any of the above examples, which will not be elaborated here.

[0026] By adopting the technical solution of the present invention, the following technical effects can be achieved: (1) By validating the certificate data to be processed, when the verification fails, the repairable anomaly is identified and the corresponding repair rule is executed. At the same time, the candidate certificate data is re-verified and continuously repaired, so as to realize the automatic diagnosis, automatic repair and repair result judgment of digital certificates, reduce certificate re-injection and manual processing, and improve the certificate recovery efficiency of vehicle network terminals. (2) By combining the error codes, error strings and certificate data format scanning results generated by validity verification, the type of anomaly is determined, thereby improving the accuracy of identifying repairable anomalies and enabling the system to call the corresponding repair rules for different anomalies; (3) By classifying repairable anomalies into start mark anomalies, end mark anomalies, certificate encoding anomalies and line break format anomalies, and configuring corresponding repair rules for each, the range of anomaly types that can be automatically repaired is expanded, and the applicability of automatic repair of digital certificates is improved. Attached Figure Description

[0027] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Figure 1 This is a flowchart illustrating an automatic repair method for digital certificates provided in an embodiment of the present invention. Detailed Implementation

[0028] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0029] See Figure 1 This is a flowchart illustrating an automatic repair method for digital certificates provided in an embodiment of the present invention.

[0030] The vehicle networking terminal described in this embodiment can be an in-vehicle infotainment system (IVI), an in-vehicle communication terminal (T-BOX), or other in-vehicle electronic devices equipped with a secure storage area. The certificate data to be processed can originate from the production line certificate injection device or from over-the-air (OTA) certificate updates during vehicle operation. Preferably, the certificate data to be processed is an X.509 digital certificate encapsulated in PEM format.

[0031] In this embodiment, a certificate management process or a certificate self-healing agent can be configured within the vehicle-to-everything (V2X) terminal. The certificate management process reads the certificate data to be processed written to the secure storage area, calls a preset certificate parsing component to perform validity verification, and invokes the corresponding repair rules when parsing fails. The preset certificate parsing component can use the OpenSSL library or other cryptographic libraries capable of parsing PEM and X.509 certificates.

[0032] It should be noted that, in this embodiment, the certificate data to be processed is preferably repaired in a temporary data buffer to generate candidate certificate data, rather than directly modifying the original certificate data in the secure storage area. The original certificate data is only updated using the candidate certificate data after the candidate certificate data passes the validity verification, thereby avoiding further damage to the original certificate data due to repair failure.

[0033] This invention provides an automatic repair method for digital certificates, the automatic repair method comprising: Step S100: Obtain the certificate data to be processed from the vehicle network terminal and determine whether the certificate data to be processed can pass the validity check; Step S110: If the validity check passes, the certificate data to be processed is determined to be valid certificate data; Specifically, after obtaining the certificate data to be processed, the vehicle-to-everything (V2X) terminal can call the PEM parsing interface or the X.509 certificate parsing interface in the OpenSSL library to parse the certificate data. If the parsing interface can correctly identify the certificate encapsulation format, decode the certificate encoding data, and obtain the corresponding X.509 certificate object, then the certificate data to be processed is determined to have passed the validity check; if the parsing interface returns an error code or error string, then the certificate data to be processed is determined to have failed the validity check.

[0034] For example, the error string returned by the parsing interface may include "error:0909006C:PEM routines:get_name:no start line", which indicates that no matching start line was found. The error string may also include "bad end line", "bad base64 decode", or ASN.1 encoded error information. Different error codes or strings can correspond to different certificate format exception types.

[0035] For certificate data that can pass the validity verification without repair, the certificate data can be directly retained, and a successful verification result can be returned to the certificate management process of the vehicle network terminal without performing subsequent repair steps.

[0036] Step S200: If the validity check fails, determine the repairable anomalies in the certificate data to be processed based on the validity check result; Step S300: Repair the certificate data to be processed according to the repair rules corresponding to the repairable anomalies, obtain candidate certificate data, and determine whether the candidate certificate data can pass the validity check; Step S410: If the validity check passes, the candidate certificate data is determined to be valid certificate data; Step S400: If the validity check fails, determine whether there are any unexecuted repair rules; Step S500: If yes, then perform the repair rules that have not yet been executed on the candidate certificate data and then re-verify the validity. Step S510: If not, then determine that the candidate certificate data is unrepairable certificate data; Step S600: Send the judgment result of the certificate data to be processed or the candidate certificate data to the vehicle network terminal.

[0037] By validating the certificate data to be processed, identifying repairable anomalies when the verification fails and executing the corresponding repair rules, and simultaneously re-verifying and continuously repairing candidate certificate data, the system achieves automatic diagnosis, automatic repair, and determination of repair results for digital certificates. This reduces certificate re-injection and manual processing, and improves the certificate recovery efficiency of vehicle networking terminals.

[0038] Further, step S200 includes: Step S210: Obtain the exception information generated by the validity check. The exception information includes the error code and / or error string. Step S220: Extract the anomaly identifier from the anomaly information, and determine the anomaly type that can be repaired based on the correspondence between the anomaly identifier and the preset anomaly type; Step S230: and / or perform a format scan on the certificate data to be processed, and determine the type of anomaly that can be repaired based on the data structure characteristics obtained from the scan.

[0039] The mapping between preset exception types and exception identifiers can be pre-stored in the certificate repair policy library. The certificate repair policy library can include the mapping relationship between exception identifiers, exception types, repair rule identifiers, and repair functions. The vehicle-to-everything (V2X) terminal queries the certificate repair policy library based on the error code or error string to determine the repair rule to be executed.

[0040] For example, when the error string includes "no start line", it can be determined that the certificate data to be processed has an abnormal start mark; when the error string includes "bad end line", it can be determined that the certificate data to be processed has an abnormal end mark; when the error string includes "bad base64 decode", it can be determined that the certificate data to be processed has an abnormal certificate encoding.

[0041] Format scanning can include: searching for a starting keyword from the beginning of the certificate data to be processed, searching for an ending keyword from the end of the certificate data to be processed, checking whether the certificate encoded data contains characters outside the preset set of legal characters, and counting the number and distribution of different types of newline characters. Format scanning can also check whether there is an abnormal number of blank lines between the boundary lines and the certificate encoded data.

[0042] By combining anomaly information matching with format scanning, the error type can be supplemented and identified when the error information returned by the parsing component is incomplete or when there are multiple format anomalies in the same certificate data.

[0043] By combining error codes, error strings, and certificate data format scanning results generated from validity checks to determine the anomaly type, the accuracy of identifying repairable anomalies is improved, enabling the system to invoke corresponding repair rules for different anomalies.

[0044] Furthermore, the repairable anomalies include at least one of the following: start mark anomaly, end mark anomaly, certificate encoding anomaly, and line break format anomaly; the repair rules include at least one of the following: start mark repair corresponding to start mark anomaly, end mark repair corresponding to end mark anomaly, certificate encoding repair corresponding to certificate encoding anomaly, and line break format repair corresponding to line break format anomaly.

[0045] In this embodiment, the first boundary marker is used to identify the starting position of the PEM object, and may include a preset separator character and a starting keyword, such as "-----BEGIN"; the second boundary marker is used to identify the ending position of the PEM object, and may include a preset separator character and an ending keyword, such as "-----END".

[0046] The first boundary line can consist of a first boundary marker, certificate type information, and a preset separator character following the certificate type information. For example, a first boundary line conforming to a preset certificate encapsulation format is “-----BEGINCERTIFICATE-----”. The second boundary line can consist of a second boundary marker, certificate type information, and a preset separator character following the certificate type information. For example, a second boundary line conforming to a preset certificate encapsulation format is “-----ENDCERTIFICATE-----”.

[0047] The certificate type information can be "CERTIFICATE". In implementations compatible with other PEM objects, the certificate type information can also be "PRIVATE KEY" or "RSA PRIVATE KEY". The default certificate type information is preferably "CERTIFICATE".

[0048] Each repair rule preferably follows the principle of minimal modification. For boundary marker anomalies and line break format anomalies, only the PEM encapsulation structure is modified; for certificate encoding anomalies, only polluting characters that do not belong to the preset legal character set are deleted, and the original order of valid encoded characters is maintained to avoid changing the valid authentication information in the digital certificate.

[0049] By classifying repairable anomalies into start mark anomalies, end mark anomalies, certificate encoding anomalies, and line break format anomalies, and configuring corresponding repair rules for each, the range of automatically repairable anomaly types is expanded, thereby improving the applicability of automatic digital certificate repair.

[0050] Furthermore, the initial marker repair includes: S310: Locate the first boundary row containing the first boundary marker in the certificate data to be processed or candidate certificate data, and determine whether certificate type information can be extracted from the first boundary row; S311: If certificate type information can be extracted, the extracted certificate type information shall be determined as the first target type information; S312: If the certificate type information cannot be extracted, the preset certificate type information will be determined as the first target type information; S313: Based on the first target type information, correct the first boundary line to a boundary line that conforms to the preset certificate encapsulation format; S314: Delete additional data located before the first boundary row.

[0051] Specifically, when performing start mark repair, the system first checks whether a UTF-8 byte order mark (BOM) exists in the header of the certificate data to be processed or the candidate certificate data. The BOM is, for example, “\xEF\xBB\xBF”. If it exists, the BOM is deleted. Then, the system scans line by line from the beginning of the certificate data to locate the first line containing the start keyword “BEGIN”, and uses this line as the first boundary line.

[0052] In one example, the standard first boundary line should be "-----BEGIN CERTIFICATE-----", while an abnormal first boundary line might be "----BEGIN CERTIFICATE-----", "------BEGIN CERTIFICATE-----", or simply "BEGIN CERTIFICATE". In this case, the first boundary line can be uniformly corrected to "-----BEGIN CERTIFICATE-----" by adding or deleting delimiters, using "BEGIN" as the starting keyword as the positioning basis.

[0053] Additional data preceding the first boundary line may include blank lines, spaces, tabs, timestamps, production line debugging logs, equipment numbers, or other diagnostic information. After locating the first boundary line, the data preceding it is identified as header additional data and deleted.

[0054] If the certificate data contains a starting keyword but the certificate type information cannot be extracted, the first target type information can be generated using the preset certificate type information "CERTIFICATE". If the certificate data does not contain a starting keyword at all, it can be determined that the starting mark repair cannot be implemented, and the certificate data is judged as unrepairable certificate data when there are no other applicable repair rules.

[0055] By determining the certificate type information in the first boundary line, correcting the first boundary line, and deleting the additional data in front of it, the certificate data has an initial structure that conforms to the preset encapsulation format, thus avoiding certificate parsing failures caused by abnormal first boundary markers or preceding interference data.

[0056] Furthermore, tail mark repair includes: S320: Locate the second boundary row containing the second boundary marker in the certificate data to be processed or the candidate certificate data, and determine whether the certificate type information can be extracted from the second boundary row; S321: If certificate type information can be extracted, the extracted certificate type information shall be determined as the second target type information; S322: If the certificate type information cannot be extracted, the preset certificate type information will be determined as the second target type information; S323: Based on the second target type information, correct the second boundary line to a boundary line that conforms to the preset certificate encapsulation format; S324: Delete additional data following the second boundary row.

[0057] Specifically, when performing tail mark repair, the system can scan line by line backward from the end of the certificate data to be processed or the candidate certificate data, locate the last line containing the "END" closing keyword, and use that line as the second boundary line. By scanning backward from the end position, the influence of certificate encoding data or preceding appended data on the location of the second boundary line can be reduced.

[0058] For example, a standard second boundary line should be "-----END CERTIFICATE-----", while an abnormal second boundary line might be "-----END CERTIFICATE----------------", a boundary line missing a dash due to transmission truncation, or a boundary line where "END" is written as "ENDD" or "EN D". For abnormal boundary lines that can be identified by the second boundary marker or end keyword, their certificate type information can be extracted and the boundary line reconstructed.

[0059] When extracting certificate type information, the string located after the closing keyword and before the trailing separator can be extracted. If extraction is successful, this string is used as the second target type information; if extraction fails or the result is empty, "CERTIFICATE" is used as the second target type information. The second boundary line is then reconstructed as "-----END {second target type information}-----".

[0060] The additional data following the second boundary line may include extra dashes, blank lines, log data, or other illegal characters. After correcting the second boundary line, all additional data following it can be deleted, ensuring that there is a newline character conforming to the preset newline rules between the second boundary line and the previous valid certificate encoding line.

[0061] By determining the certificate type information in the second boundary line, correcting the second boundary line, and deleting the additional data following it, the certificate data has an ending structure that conforms to the preset encapsulation format, thus avoiding certificate parsing failures caused by abnormal first boundary markers or trailing interference data.

[0062] Furthermore, certificate encoding repair includes: S330: Extract certificate encoding data from the certificate data to be processed or candidate certificate data; S331: Based on a preset set of valid characters, retain valid encoded characters from the certificate encoded data and remove invalid encoded characters; S332: Reorganize the retained valid encoded characters according to the preset data organization rules.

[0063] For example, certificate encoding data can be a Base64 encoded payload located between the first and second boundary lines that conform to a preset certificate encapsulation format. When performing certificate encoding repair, the complete first and second boundary lines can be located first, and then all data between them can be extracted as certificate encoding data.

[0064] The preset set of legal characters can include uppercase letters AZ, lowercase letters az, numbers 0-9, plus sign "+", forward slash " / ", and equal sign "=" as a filler character. During the character filtering stage, the above legal encoded characters can be retained, while spaces, tabs "\t", redundant dashes, illegal symbols, and invisible control characters can be removed.

[0065] For example, certificate encoding data may contain consecutive dashes, device numbers, timestamps, or inline spaces due to production line debugging tools or buffer remnants, causing the parsing component to return "bad base64 decode". Certificate encoding repair only removes these illegal contaminant characters while maintaining the original order of the legal encoded characters.

[0066] Reorganizing the data according to preset data organization rules may include: concatenating the retained valid encoded characters into a continuous string, deleting the original newline characters within the continuous string, and then re-dividing it into lines of a preset line length of 64 characters per line; for cases where the last line has less than 64 characters, retaining its actual number of characters. Finally, re-encapsulating the data in the order of "first boundary line, newline character, re-divided certificate encoded data, newline character, and second boundary line" to obtain the candidate certificate data.

[0067] By preserving valid encoded characters in the certificate encoding data, removing invalid encoded characters, and reorganizing valid encoded characters, the valid format of the certificate encoding data is restored, thereby improving the success rate of repairing certificates that fail to be parsed due to abnormal characters mixed in the encoding data.

[0068] Furthermore, line break formatting correction includes: S340: Convert non-target newline characters in the certificate data to be processed or candidate certificate data to target newline characters; S341: Delete redundant blank lines in pending certificate data or candidate certificate data; S342: Set the line spacing and end position of the certificate data to be processed or candidate certificate data according to the preset line break rules; In cases where the recoverable anomalies include at least one of the start mark anomalies and certificate encoding anomalies, line break format repair is performed first, followed by repair corresponding to each of the identified recoverable anomalies.

[0069] Specifically, line break formatting errors can be caused by data transmission between different operating systems, HTTP serialization or deserialization, serial communication, and data processing by diagnostic tools. For example, the same certificate data may contain Windows-formatted "\r\n", older Mac-formatted "\r", and Unix-formatted "\n" simultaneously; there may also be multiple consecutive blank lines after the first boundary line or before the second boundary line.

[0070] In one implementation, the target newline character is "\n". Newline formatting can be corrected by converting "\r\n" and any standalone "\r" characters in the certificate data to "\n", and then splitting the certificate data into multiple lines based on "\n".

[0071] When deleting redundant blank lines, the first boundary line, the first valid certificate code line, the last valid certificate code line, and the second boundary line can be located. At most one blank line is allowed between the first boundary line and the first valid certificate code line, and at most one blank line is allowed between the last valid certificate code line and the second boundary line. All other consecutive blank lines are deleted.

[0072] When setting the end position of the file, you can ensure that there is exactly one target newline character after the second boundary line, so as to guarantee that the certificate file ends with a newline character and improve the compatibility between different parsing components.

[0073] Line break formatting repair can be performed independently when format scanning detects mixed use of line breaks or an abnormal number of blank lines, or it can be performed as a prerequisite step when start mark repair or certificate encoding repair is triggered.

[0074] By standardizing line breaks in certificate data, deleting redundant blank lines, and adjusting line spacing and file end positions, the impact of different line break formats on certificate parsing is eliminated. At the same time, performing line break format repair before start mark repair or certificate encoding repair can provide certificate data with a uniform format for subsequent repairs, improving the reliability of subsequent repairs.

[0075] Furthermore, the default execution order of the repair rules is as follows: newline format repair, start mark repair, end mark repair, and certificate encoding repair.

[0076] Specifically, after determining that there are one or more repairable anomalies in the certificate data to be processed, the line break format can be repaired first to obtain candidate certificate data with uniform line break format; then, the applicable repair rules are scheduled in the order of start mark repair, tail mark repair and certificate encoding repair.

[0077] Each time a remediation rule is executed, the certificate resolution component is invoked to verify the validity of the currently generated candidate certificate data. If the current candidate certificate data passes the validity verification, the execution of the remaining remediation rules is immediately stopped to avoid unnecessary modifications to the certificate data; if the validity verification fails, the current candidate certificate data is used as the processing object for the next remediation rule, allowing the remediation results from multiple remediations to be cumulative.

[0078] For example, if a certificate data set has issues such as mixed line breaks, an incorrect number of dashes on the first boundary line, and tabs mixed in with the certificate encoding data, the line breaks can be standardized first, then the first boundary line can be corrected, and finally, illegal characters in the certificate encoding data can be filtered out. A validity check is performed again after each step, and subsequent processing terminates once any step's check is successful.

[0079] If all applicable repair rules have been executed and the current candidate certificate data still fails the validity check, then the candidate certificate data will be determined as unrepairable certificate data, and a corresponding error report or failure result will be generated.

[0080] By executing the repair rules in the order of line break format repair, start mark repair, end mark repair, and certificate encoding repair, the mutual interference between different repair operations is reduced, enabling multiple anomalies to be repaired step by step in the order from basic format to encoded content, thereby improving the repair efficiency and success rate of multi-anomaly certificates.

[0081] Further, step S600 includes: Step S610: If the certificate data to be processed or the candidate certificate data is determined to be valid certificate data, the certificate data to be processed or the candidate certificate data is written into the certificate storage area of ​​the vehicle network terminal, and the repairable anomaly, the repair rule executed and the repair time corresponding to this repair are recorded. Step S620: If the certificate data to be processed or the candidate certificate data is determined to be unrepairable certificate data, a manual repair request is sent to the vehicle network terminal.

[0082] Specifically, after the candidate certificate data passes validity verification, it can be written to the secure storage area of ​​the vehicle-to-everything (V2X) terminal using an atomic write method. An atomic write can include: first writing the candidate certificate data to a temporary storage location; then, after confirming the write is complete, switching the temporary storage location to the official certificate storage location, thereby preventing incomplete official certificate data due to write process anomalies.

[0083] For pending certificate data that is determined to be valid without repair, a certificate verification success log can be recorded; for candidate certificate data that is determined to be valid after repair, a repair log can be recorded. The repair log can include the original error code of the pending certificate data, the original error string, the identified repairable exceptions, the actual repair rules executed, the execution results of each repair rule, and the repair timestamp.

[0084] When candidate certificate data is determined to be unrepairable, the vehicle-to-everything (V2X) terminal can send a manual repair request or certificate unrepairable information to the certificate management process, which will then report it to the production line host computer, certificate injection device, or back-end certificate management device to trigger certificate re-issuance, re-download, or manual processing.

[0085] By writing the certificate data that is determined to be valid into the certificate storage area of ​​the vehicle-to-everything (V2X) terminal and recording the anomaly type, repair rules and repair time, the practical application of the repair results and the traceability of the repair process are realized; when the certificate cannot be repaired, a manual repair request is sent to facilitate timely follow-up processing.

[0086] In a specific example, the certificate data header received by the vehicle-to-everything (V2X) terminal contains a UTF-8 BOM and a production line timestamp. The first boundary line is “----BEGIN CERTIFICATE-----”, some certificate encoding lines contain tabs, the second boundary line is “-----END CERTIFICATE----------------”, and the certificate data contains both “\r\n” and “\n”.

[0087] The vehicle-to-everything (V2X) terminal first calls the OpenSSL library to parse the certificate data and determines that there are repairable anomalies in the certificate data based on "no start line" or other parsing errors. Then, the V2X terminal unifies "\r\n" to "\n" and deletes redundant blank lines; removes the production line timestamp before the UTF-8 BOM and the first boundary line, and corrects the first boundary line to "-----BEGIN CERTIFICATE-----"; locates the second boundary line from the end of the data, corrects it to "-----ENDCERTIFICATE-----", and deletes any subsequent dashes; finally, it filters out tabs in the certificate encoding data and reorganizes the certificate encoding data into 64-character lines.

[0088] After each repair is completed, the OpenSSL library is invoked to re-parse the current candidate certificate data. When the candidate certificate data is successfully parsed, the execution of any unexecuted repair rules is stopped, and the candidate certificate data is written to a secure storage area using an atomic write method. Simultaneously, the original error code, the executed repair rule, and the repair time are recorded. This process allows for the recovery of digital certificates that cannot be parsed due to occasional format contamination without reapplying for a certificate from the backend PKI system.

[0089] On the other hand, the present invention also provides an automatic repair system for digital certificates, comprising: The certificate acquisition module is used to acquire the certificate data to be processed from the vehicle networking terminal; The verification module is used to determine whether the certificate data to be processed can pass the validity verification. The anomaly detection module is used to determine repairable anomalies in the certificate data to be processed based on the validity check results when the certificate data to be processed fails the validity check. The repair module is used to repair the certificate data to be processed according to the repair rules corresponding to the repairable anomalies, and obtain candidate certificate data. The verification module is also used to determine whether candidate certificate data can pass the validity check; The rule judgment module is used to determine whether there are any unexecuted repair rules when candidate certificate data fails the validity check. The repair module is also used to execute unexecuted repair rules on candidate certificate data if there are existing unexecuted repair rules. The verification module is also used to re-verify the validity of the candidate certificate data after the repair module has executed the repair rules that have not yet been executed on the candidate certificate data; The certificate determination module is used to determine the certificate data to be processed as valid certificate data if the certificate data to be processed passes the validity check, to determine the candidate certificate data as valid certificate data if the candidate certificate data passes the validity check, and to determine the candidate certificate data as unrepairable certificate data if the candidate certificate data fails the validity check and there are no unexecuted repair rules. The result sending module is used to send the determination results of the certificate data to be processed or the candidate certificate data to the vehicle network terminal.

[0090] Correspondingly, in this embodiment, the technical effects corresponding to any of the above-described technical solutions can be achieved, which will not be elaborated here.

[0091] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the invention; therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.

Claims

1. An automatic repair method for digital certificates, characterized in that, The automatic repair method includes: Obtain the certificate data to be processed from the vehicle network terminal, and determine whether the certificate data to be processed can pass the validity check; If the validity check passes, the certificate data to be processed is determined to be valid certificate data; if the validity check fails, a repairable anomaly is determined in the certificate data to be processed based on the validity check result. The certificate data to be processed is repaired according to the repair rules corresponding to the repairable anomalies to obtain candidate certificate data, and it is determined whether the candidate certificate data can pass the validity check. If the validity check is passed, the candidate certificate data is determined to be valid certificate data; if the validity check is not passed, it is determined whether there are any unexecuted repair rules. If yes, then the unexecuted repair rules are applied to the candidate certificate data and the validity is re-verified; if no, then the candidate certificate data is determined to be unrepairable certificate data. The determination result of the certificate data to be processed or the candidate certificate data is sent to the vehicle network terminal.

2. The automatic repair method according to claim 1, characterized in that, The step of determining repairable anomalies in the certificate data to be processed based on the validity verification result includes: Obtain the exception information generated by the validity check, the exception information including error code and / or error string; Extract an anomaly identifier from the anomaly information, and determine the anomaly type of the repairable anomaly based on the correspondence between the anomaly identifier and a preset anomaly type; and / or The format of the certificate data to be processed is scanned, and the anomaly type of the repairable anomaly is determined based on the data structure characteristics obtained from the scan.

3. The automatic repair method according to claim 2, characterized in that, The repairable anomalies include at least one of the following: start mark anomaly, end mark anomaly, certificate encoding anomaly, and line break format anomaly. The repair rules include at least one of the following: start mark repair corresponding to the start mark anomaly, tail mark repair corresponding to the tail mark anomaly, certificate encoding repair corresponding to the certificate encoding anomaly, and line break format repair corresponding to the line break format anomaly.

4. The automatic repair method according to claim 3, characterized in that, The initial marker repair includes: Locate the first boundary row containing the first boundary marker in the certificate data to be processed or the candidate certificate data, and determine whether certificate type information can be extracted from the first boundary row; If the certificate type information can be extracted, the extracted certificate type information will be identified as the first target type information. If the certificate type information cannot be extracted, the preset certificate type information will be determined as the first target type information; Based on the first target type information, the first boundary line is corrected to a boundary line that conforms to the preset certificate encapsulation format; Delete any additional data located before the first boundary row.

5. The automatic repair method according to claim 3, characterized in that, The tail marker repair includes: Locate the second boundary row containing the second boundary marker in the certificate data to be processed or the candidate certificate data, and determine whether certificate type information can be extracted from the second boundary row; If the certificate type information can be extracted, the extracted certificate type information will be identified as the second target type information. If the certificate type information cannot be extracted, the preset certificate type information will be determined as the second target type information; Based on the second target type information, the second boundary line is corrected to a boundary line that conforms to the preset certificate encapsulation format; Delete any additional data following the second boundary row.

6. The automatic repair method according to claim 3, characterized in that, The certificate encoding repair includes: Extract the certificate encoding data from the certificate data to be processed or the candidate certificate data; Based on a preset set of legal characters, retain valid encoded characters and remove invalid encoded characters from the certificate encoded data; The retained valid encoded characters are reorganized according to the preset data organization rules.

7. The automatic repair method according to claim 3, characterized in that, The line break formatting repair includes: Convert non-target newline characters in the certificate data to be processed or the candidate certificate data into target newline characters; Delete any extra blank lines in the certificate data to be processed or the candidate certificate data; Set the line spacing and file end position of the certificate data to be processed or the candidate certificate data according to the preset line break rules; In cases where the repairable anomaly includes at least one of the start mark anomaly and the certificate encoding anomaly, the line break format repair is performed first, followed by the start mark repair and the certificate encoding repair.

8. The automatic repair method according to claim 3, characterized in that, The preset execution order of the repair rules is as follows: line break format repair, start mark repair, end mark repair, and certificate encoding repair.

9. The automatic repair method according to claim 1, characterized in that, The determination result of sending the certificate data to be processed or the candidate certificate data to the vehicle network terminal includes: If the certificate data to be processed or the candidate certificate data is determined to be valid certificate data, the certificate data to be processed or the candidate certificate data is written into the certificate storage area of ​​the vehicle network terminal, and the repairable anomaly, the repair rule executed and the repair time corresponding to this repair are recorded. If the certificate data to be processed or the candidate certificate data is determined to be unrepairable certificate data, a manual repair request is sent to the vehicle network terminal.

10. An automatic repair system for digital certificates, characterized in that, include: The certificate acquisition module is used to acquire the certificate data to be processed from the vehicle networking terminal; The verification module is used to determine whether the certificate data to be processed can pass the validity verification. An anomaly determination module is used to determine, based on the validity check result, a repairable anomaly in the certificate data to be processed when the certificate data to be processed fails the validity check. The repair module is used to repair the certificate data to be processed according to the repair rules corresponding to the repairable anomalies, and obtain candidate certificate data; The verification module is also used to determine whether the candidate certificate data can pass the validity verification. The rule judgment module is used to determine whether there are any unexecuted repair rules when the candidate certificate data fails the validity check. The repair module is also used to execute the unexecuted repair rules on the candidate certificate data if there are unexecuted repair rules. The verification module is also used to re-verify the validity of the candidate certificate data after the repair module executes the repair rules that have not yet been executed on the candidate certificate data; The certificate determination module is used to determine the certificate data to be processed as valid certificate data when the certificate data to be processed passes the validity check, to determine the candidate certificate data as valid certificate data when the candidate certificate data passes the validity check, and to determine the candidate certificate data as unrepairable certificate data when the candidate certificate data fails the validity check and there are no unexecuted repair rules. The result sending module is used to send the judgment result of the certificate data to be processed or the candidate certificate data to the vehicle network terminal.