seckit/test-cert.js
cheney 32626c84a6
All checks were successful
Build and Deploy / build (push) Successful in 56s
一些证书测试代码
2026-04-24 15:52:59 +08:00

23 lines
794 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 测试证书模块
import { generateRootCert, generateAppCert, parseSm2Cert } from './src/utils/algorithm/cert.js'
// 测试生成根证书
console.log('=== 测试生成根证书 ===')
try {
const rootCert = generateRootCert()
console.log('根证书生成成功!')
console.log('根证书内容前200字符:', rootCert.substring(0, 200) + '...')
} catch (error) {
console.error('生成根证书失败:', error.message)
}
// 测试生成应用证书
console.log('\n=== 测试生成应用证书 ===')
try {
const appCert = generateAppCert('test.example.com')
console.log('应用证书生成成功!')
console.log('应用证书内容前200字符:', appCert.substring(0, 200) + '...')
} catch (error) {
console.error('生成应用证书失败:', error.message)
}