feat: HSM main/slave certificate comparison with batch SQL generation

- compare usercert_tab by subject raw bytes + certtype
- generate single annotated CSV report
- generate merge-<timestamp>.sql in current directory for DBA execution
- preserve GBK DN bytes via ATTACH + INSERT OR REPLACE / UPDATE
- compatible with sqlite3 3.6.20 and JDK 1.8
This commit is contained in:
cheney
2026-11-04 15:18:42 +08:00
commit fe28ddeaac
38 changed files with 4952 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
-- 在从库中增加 3 条用于测试“不一致”的证书。
-- 与 main-test-data.sql 配合:同一 DN + certtype 在两边都存在,但字段不同。
-- 执行前请备份 slave.db。
-- 1) SN 不一致:main=0A0B0C01 / slave=0A0B0C11
INSERT INTO usercert_tab
(organid, subject, issuer, sn, pubkey_alg, pubkey, sign_alg, signinfo,
not_before, not_after, certfile, certtype, opertime, stat)
SELECT organid, 'CN=diff-sn-01', issuer, '0A0B0C11', pubkey_alg, pubkey, sign_alg, signinfo,
'20260101000000', '20301231235959', certfile, 0, opertime, 0
FROM usercert_tab ORDER BY rowid LIMIT 1;
-- 2) 有效期不一致:main 失效 2030 / slave 失效 2031
INSERT INTO usercert_tab
(organid, subject, issuer, sn, pubkey_alg, pubkey, sign_alg, signinfo,
not_before, not_after, certfile, certtype, opertime, stat)
SELECT organid, 'CN=diff-time-02', issuer, '0A0B0C02', pubkey_alg, pubkey, sign_alg, signinfo,
'20260101000000', '20311231235959', certfile, 2, opertime, 0
FROM usercert_tab ORDER BY rowid LIMIT 1;
-- 3) 状态不一致:main stat=0 / slave stat=1
INSERT INTO usercert_tab
(organid, subject, issuer, sn, pubkey_alg, pubkey, sign_alg, signinfo,
not_before, not_after, certfile, certtype, opertime, stat)
SELECT organid, 'CN=diff-stat-03', issuer, '0A0B0C03', pubkey_alg, pubkey, sign_alg, signinfo,
'20260101000000', '20301231235959', certfile, 5, opertime, 1
FROM usercert_tab ORDER BY rowid LIMIT 1;