tomsun28 commented on code in PR #3474:
URL: https://github.com/apache/hertzbeat/pull/3474#discussion_r2154917490
##########
hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/mqtt/CertificateFormatter.java:
##########
@@ -0,0 +1,184 @@
+package org.apache.hertzbeat.collector.collect.mqtt;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class CertificateFormatter {
+
+ /**
+ * 格式化证书字符串,支持处理多个证书
+ */
+ public static String formatCertificateChain(String input) {
+ if (input == null || input.trim().isEmpty()) {
+ return input;
+ }
+
+ // 标准化输入格式
+ String normalized = normalizeInput(input);
+
+ // 提取所有证书块
+ List<String> certificates = extractCertificates(normalized);
+
+ // 如果没有找到证书块,尝试作为纯内容处理
+ if (certificates.isEmpty()) {
+ return formatAsSingleCertificate(normalized);
+ }
+
+ // 格式化每个证书块
+ StringBuilder formattedChain = new StringBuilder();
+ for (String cert : certificates) {
+ // 防止空证书块
Review Comment:
hi please use the english, add license header.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]