Skip to content

Commit

Permalink
#524 Enable removing NOC root certificates
Browse files Browse the repository at this point in the history
Refactor impl

Signed-off-by: Abdulbois <[email protected]>
Signed-off-by: Abdulbois <[email protected]>
  • Loading branch information
Abdulbois committed May 7, 2024
1 parent 9d29610 commit c9cb99b
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions x/pki/keeper/msg_server_remove_noc_x_509_root_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (k msgServer) RemoveNocX509RootCert(goCtx context.Context, msg *types.MsgRe
k.removeApprovedX509Cert(ctx, certID, &aprCerts, msg.SerialNumber)

// Remove from NOC lists
removeCertFromList(certBySerialNumber.Issuer, certBySerialNumber.SerialNumber, &nocCerts.Certs)
k._removeNocX509RootCert(ctx, certID, &nocCerts, msg.SerialNumber)
k.RemoveNocRootCertificateBySerialNumber(ctx, nocCerts.Vid, certID.Subject, certID.SubjectKeyId, msg.SerialNumber)
k.RemoveNocRootCertificateByVidSubjectSkidAndSerialNumber(ctx, nocCerts.Vid, certID.Subject, certID.SubjectKeyId, msg.SerialNumber)
}

if foundRevoked {
Expand Down Expand Up @@ -86,16 +86,6 @@ func (k msgServer) RemoveNocX509RootCert(goCtx context.Context, msg *types.MsgRe
return &types.MsgRemoveNocX509RootCertResponse{}, nil
}

func (k msgServer) _removeNocX509RootCert(ctx sdk.Context, certID types.CertificateIdentifier, certificates *types.NocRootCertificatesByVidAndSkid, serialNumber string) {
if len(certificates.Certs) == 0 {
k.RemoveNocRootCertificate(ctx, certificates.Vid, certID.Subject, certID.SubjectKeyId)
k.RemoveNocRootCertificatesByVidAndSkid(ctx, certificates.Vid, certID.SubjectKeyId)
} else {
k.RemoveNocRootCertificateBySerialNumber(ctx, certificates.Vid, certID.Subject, certID.SubjectKeyId, serialNumber)
k.RemoveNocRootCertificateByVidSubjectSkidAndSerialNumber(ctx, certificates.Vid, certID.Subject, certID.SubjectKeyId, serialNumber)
}
}

func (k msgServer) _removeRevokedNocX509RootCert(ctx sdk.Context, certID types.CertificateIdentifier, certificates *types.RevokedNocRootCertificates) {
if len(certificates.Certs) == 0 {
k.RemoveRevokedNocRootCertificates(ctx, certID.Subject, certID.SubjectKeyId)
Expand Down

0 comments on commit c9cb99b

Please sign in to comment.