证书作为公钥进行验证
This commit is contained in:
@@ -4,11 +4,9 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"omc/conf"
|
||||
"omc/core/db"
|
||||
"omc/core/utils"
|
||||
"omc/handle/model"
|
||||
"os"
|
||||
|
||||
"github.com/aceld/zinx/zlog"
|
||||
)
|
||||
@@ -32,14 +30,9 @@ func UserLogin(name, passwd string) error {
|
||||
// CMCALogin 验证随机码
|
||||
// content "user:seqNo" 组合的字符
|
||||
// signatureBase64 签名数据(base64编码)
|
||||
func CMCALogin(content, signatureBase64 string) error {
|
||||
// 读取文件内容
|
||||
strByte, err := os.ReadFile(conf.OmcConf.PublicKey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("无法读取文件 %v", err)
|
||||
}
|
||||
func CMCALogin(publicKeyStr, content, signatureBase64 string) error {
|
||||
// 公钥
|
||||
publicKeyPEM := fmt.Sprintf("-----BEGIN RSA PUBLIC KEY-----\n %s \n-----END RSA PUBLIC KEY-----", strByte)
|
||||
publicKeyPEM := fmt.Sprintf("-----BEGIN RSA PUBLIC KEY-----\n %s \n-----END RSA PUBLIC KEY-----", publicKeyStr)
|
||||
|
||||
// 解析公钥
|
||||
publicKey, err := utils.ParsePKCS1PublicKey(publicKeyPEM)
|
||||
|
||||
Reference in New Issue
Block a user