Skip to content

Commit 634236b

Browse files
committed
#535 Enable providing serial number while revoking x509 certs
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com> Signed-off-by: Abdulbois <abdulbois123@gmail.com>
1 parent 1be8186 commit 634236b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

x/pki/keeper/approved_certificates.go

+20
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ func (k Keeper) RemoveApprovedCertificates(
7070
))
7171
}
7272

73+
func (k Keeper) removeCertFromList(serialNumber string, certs *types.ApprovedCertificates) {
74+
certIndex := -1
75+
76+
for i, cert := range certs.Certs {
77+
if cert.SerialNumber == serialNumber {
78+
certIndex = i
79+
80+
break
81+
}
82+
}
83+
if certIndex == -1 {
84+
return
85+
}
86+
if certIndex == len(certs.Certs)-1 {
87+
certs.Certs = certs.Certs[:certIndex]
88+
} else {
89+
certs.Certs = append(certs.Certs[:certIndex], certs.Certs[certIndex+1:]...)
90+
}
91+
}
92+
7393
// GetAllApprovedCertificates returns all approvedCertificates.
7494
func (k Keeper) GetAllApprovedCertificates(ctx sdk.Context) (list []types.ApprovedCertificates) {
7595
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.ApprovedCertificatesKeyPrefix))

0 commit comments

Comments
 (0)