pkcs7: fix error

This commit is contained in:
Sun Yimin 2023-03-09 14:32:50 +08:00 committed by GitHub
parent 9a839b50c0
commit 1d1382f085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ type signedEnvelopedData struct {
SignerInfos []signerInfo `asn1:"set"` SignerInfos []signerInfo `asn1:"set"`
} }
func (data signedEnvelopedData) findRecipient(cert *smx509.Certificate) *recipientInfo { func (data signedEnvelopedData) GetRecipient(cert *smx509.Certificate) *recipientInfo {
for _, recp := range data.RecipientInfos { for _, recp := range data.RecipientInfos {
if isCertMatchForIssuerAndSerial(cert, recp.IssuerAndSerialNumber) { if isCertMatchForIssuerAndSerial(cert, recp.IssuerAndSerialNumber) {
return &recp return &recp
@ -93,7 +93,7 @@ func (p7 *PKCS7) DecryptAndVerify(cert *smx509.Certificate, pkey crypto.PrivateK
if !ok { if !ok {
return nil, errors.New("pkcs7: it's NOT SignedAndEvelopedData") return nil, errors.New("pkcs7: it's NOT SignedAndEvelopedData")
} }
recipient := sed.findRecipient(cert) recipient := sed.GetRecipient(cert)
if recipient == nil { if recipient == nil {
return nil, errors.New("pkcs7: no enveloped recipient for provided certificate") return nil, errors.New("pkcs7: no enveloped recipient for provided certificate")
} }