Skip to content

Commit a167dc6

Browse files
validateSigTime returns true when valid
1 parent eef8cbc commit a167dc6

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

std/security/trust_config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (tc *TrustConfig) Validate(args TrustConfigValidateArgs) {
206206
return
207207
}
208208

209-
if args.UseSignatureTime.GetOr(false) && ValidateSigTime(args.Data, args.cert) {
209+
if args.UseSignatureTime.GetOr(false) && !ValidateSigTime(args.Data, args.cert) {
210210
args.Callback(false, fmt.Errorf("data not signed during validity period: %s", args.cert.Name()))
211211
return
212212
}
@@ -416,7 +416,7 @@ func (tc *TrustConfig) validateCrossSchema(args TrustConfigValidateArgs) {
416416
// Check validity period of the cross schema
417417
if args.UseSignatureTime.GetOr(false) {
418418
// Cross schema was valid at signature time
419-
if ValidateSigTime(args.Data, crossData) {
419+
if !ValidateSigTime(args.Data, crossData) {
420420
args.Callback(false, fmt.Errorf("cross schema signature time invalid: %s", crossData.Name()))
421421
return
422422
}
@@ -694,22 +694,22 @@ func (tc *TrustConfig) tryListedCerts(args certListArgs, names []enc.Name, idx i
694694
// Returns true if signature time is within certificate validity period
695695
func ValidateSigTime(data ndn.Data, cert ndn.Data) bool {
696696
if cert.Signature() == nil {
697-
return true
697+
return false
698698
}
699699

700700
sigTime := data.Signature().SigTime()
701701

702702
if sigTime == nil {
703-
return true
703+
return false
704704
}
705705

706706
notBefore, notAfter := cert.Signature().Validity()
707707
if val, ok := notBefore.Get(); !ok || sigTime.Before(val) {
708-
return true
708+
return false
709709
}
710710
if val, ok := notAfter.Get(); !ok || sigTime.After(val) {
711-
return true
711+
return false
712712
}
713713

714-
return false
714+
return true
715715
}

0 commit comments

Comments
 (0)