plugin/alipay/utils/mch_cert.go

23 lines
471 B
Go

package utils
import (
"fmt"
"io/ioutil"
"log"
)
// getMchCertSN 提取证书序列号
func getMchCertSN(certPath string) (string, error) {
certData, err := ioutil.ReadFile(certPath)
if err != nil {
log.Fatalf("Failed to read the cert file: %s", err)
}
cert, err := getCert(certData)
if err != nil {
return "", fmt.Errorf("failed to parse certificate: %v", err)
}
return md5Hash(cert.Issuer.ToRDNSequence().String() + cert.SerialNumber.String()), nil
}