Skip to content

Commit 742798a

Browse files
remove IgnoreValidity and introduce UseSignatureTime in SVS and repo
1 parent a167dc6 commit 742798a

14 files changed

Lines changed: 46 additions & 53 deletions

repo/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ type Config struct {
1717
KeyChainUri string `json:"keychain"`
1818
// List of trust anchor full names.
1919
TrustAnchors []string `json:"trust_anchors"`
20-
// IgnoreValidity skips validity period checks when fetching remote data (e.g. SVS snapshots).
21-
IgnoreValidity bool `json:"ignore_validity"`
2220

2321
// NameN is the parsed name of the repo service.
2422
NameN enc.Name

repo/repo_mgmt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ func (r *Repo) fetchSecurityConfig(name enc.Name) (*tlv.SecurityConfigObject, er
197197

198198
// Repo should validate this as normal command
199199
r.client.ConsumeExt(ndn.ConsumeExtArgs{
200-
Name: name,
201-
TryStore: true,
202-
IgnoreValidity: optional.Some(r.config.IgnoreValidity),
200+
Name: name,
201+
TryStore: true,
202+
UseSignatureTime: optional.Some(true),
203203
Callback: func(state ndn.ConsumeState) {
204204
wire = append(wire, state.Content()...)
205205
if state.Error() != nil {

repo/repo_svs.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ func (r *RepoSvs) Start() (err error) {
5454
}
5555

5656
snapshot = &ndn_sync.SnapshotNodeHistory{
57-
Client: r.client,
58-
Threshold: r.cmd.HistorySnapshot.Threshold,
59-
IsRepo: true,
60-
IgnoreValidity: optional.Some(r.config.IgnoreValidity),
57+
Client: r.client,
58+
Threshold: r.cmd.HistorySnapshot.Threshold,
59+
IsRepo: true,
60+
UseSignatureTime: optional.Some(true),
6161
}
6262
}
6363

@@ -78,7 +78,7 @@ func (r *RepoSvs) Start() (err error) {
7878
SuppressionPeriod: 500 * time.Millisecond,
7979
PeriodicTimeout: 365 * 24 * time.Hour, // basically never
8080
Passive: true,
81-
IgnoreValidity: optional.Some(r.config.IgnoreValidity),
81+
UseSignatureTime: optional.Some(true),
8282
},
8383
Snapshot: snapshot,
8484
MulticastPrefix: multicastPrefix,

std/ndn/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ type ConsumeExtArgs struct {
129129
OnProgress func(status ConsumeState)
130130
// NoMetadata disables fetching RDR metadata (advanced usage).
131131
NoMetadata bool
132-
// IgnoreValidity ignores validity period in the validation chain
133-
IgnoreValidity optional.Optional[bool]
132+
// UseSignatureTime checks validity period using signature time
133+
UseSignatureTime optional.Optional[bool]
134134
}
135135

136136
// ExpressRArgs are the arguments for the express retry API.
@@ -167,8 +167,8 @@ type ValidateExtArgs struct {
167167
CertNextHop optional.Optional[uint64]
168168
// UseDataNameFwHint overrides trust config option.
169169
UseDataNameFwHint optional.Optional[bool]
170-
// IgnoreValidity ignores validity period in the validation chain.
171-
IgnoreValidity optional.Optional[bool]
170+
// UseSignatureTime checks validity with signature time
171+
UseSignatureTime optional.Optional[bool]
172172
}
173173

174174
// Announcement are the arguments for the announce prefix API.

std/ndn/engine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ type ExpressCallbackArgs struct {
8989
// IsLocal indicates if a local copy of the Data was found.
9090
// e.g. returned by ExpressR when used with TryStore.
9191
IsLocal bool
92+
93+
UseSignatureTime optional.Optional[bool]
9294
}
9395

9496
// InterestHandler represents the callback function for an Interest handler.

std/object/client_consume.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (c *Client) consumeObject(state *ConsumeState) {
6464
// if metadata fetching is disabled, just attempt to fetch one segment
6565
// with the prefix, then get the versioned name from the segment.
6666
if state.args.NoMetadata {
67-
c.fetchDataByPrefix(name, state.args.TryStore,
67+
c.fetchDataByPrefix(name, state.args.TryStore, state.args.UseSignatureTime.GetOr(false),
6868
func(data ndn.Data, err error) {
6969
if err != nil {
7070
state.finalizeError(err)
@@ -81,7 +81,7 @@ func (c *Client) consumeObject(state *ConsumeState) {
8181
}
8282

8383
// fetch RDR metadata for this object
84-
c.fetchMetadata(name, state.args.TryStore,
84+
c.fetchMetadata(name, state.args.TryStore, state.args.UseSignatureTime.GetOr(false),
8585
func(meta *rdr.MetaData, err error) {
8686
if err != nil {
8787
state.finalizeError(err)
@@ -107,6 +107,7 @@ func (c *Client) consumeObjectWithMeta(state *ConsumeState, meta *rdr.MetaData)
107107
func (c *Client) fetchMetadata(
108108
name enc.Name,
109109
tryStore bool,
110+
useSignatureTime bool,
110111
callback func(meta *rdr.MetaData, err error),
111112
) {
112113
log.Debug(c, "Fetching object metadata", "name", name)
@@ -130,8 +131,9 @@ func (c *Client) fetchMetadata(
130131
return
131132
}
132133
c.ValidateExt(ndn.ValidateExtArgs{
133-
Data: args.Data,
134-
SigCovered: args.SigCovered,
134+
Data: args.Data,
135+
SigCovered: args.SigCovered,
136+
UseSignatureTime: optional.Some(useSignatureTime),
135137
Callback: func(valid bool, err error) {
136138
// validate with trust config
137139
if !valid {
@@ -160,6 +162,7 @@ func (c *Client) fetchMetadata(
160162
func (c *Client) fetchDataByPrefix(
161163
name enc.Name,
162164
tryStore bool,
165+
useSignatureTime bool,
163166
callback func(data ndn.Data, err error),
164167
) {
165168
log.Debug(c, "Fetching data with prefix", "name", name)
@@ -183,8 +186,9 @@ func (c *Client) fetchDataByPrefix(
183186
return
184187
}
185188
c.ValidateExt(ndn.ValidateExtArgs{
186-
Data: args.Data,
187-
SigCovered: args.SigCovered,
189+
Data: args.Data,
190+
SigCovered: args.SigCovered,
191+
UseSignatureTime: optional.Some(useSignatureTime),
188192
Callback: func(valid bool, err error) {
189193
if !valid {
190194
callback(nil, fmt.Errorf("%w: validate by prefix failed: %w", ndn.ErrSecurity, err))

std/object/client_consume_seg.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ func (s *rrSegFetcher) handleResult(args ndn.ExpressCallbackArgs, state *Consume
286286
// The notable exception here is when there is a timeout, which has a separate goroutine.
287287
func (s *rrSegFetcher) handleData(args ndn.ExpressCallbackArgs, state *ConsumeState) {
288288
s.client.ValidateExt(ndn.ValidateExtArgs{
289-
Data: args.Data,
290-
SigCovered: args.SigCovered,
291-
IgnoreValidity: state.args.IgnoreValidity,
289+
Data: args.Data,
290+
SigCovered: args.SigCovered,
291+
UseSignatureTime: state.args.UseSignatureTime,
292292
Callback: func(valid bool, err error) {
293293
if !valid {
294294
state.finalizeError(fmt.Errorf("%w: validate seg failed: %w", ndn.ErrSecurity, err))

std/object/client_trust.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func (c *Client) ValidateExt(args ndn.ValidateExtArgs) {
4646
Callback: args.Callback,
4747
OverrideName: overrideName,
4848
UseDataNameFwHint: args.UseDataNameFwHint,
49+
UseSignatureTime: args.UseSignatureTime,
4950
Fetch: func(name enc.Name, config *ndn.InterestConfig, callback ndn.ExpressCallbackFunc) {
5051
config.NextHopId = args.CertNextHop
5152
c.ExpressR(ndn.ExpressRArgs{

std/security/keychain/keychain_state.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ func (kc *keyChainState) insertCert(wire []byte) error {
119119
return ndn.ErrInvalidValue{Item: "certificate name"}
120120
}
121121

122-
// Check if certificate is valid
123-
if sec.CertIsExpired(data) {
124-
return ndn.ErrInvalidValue{Item: "certificate expiry"}
125-
}
126-
127122
// Check if certificate already exists
128123
for _, existing := range kc.certNames {
129124
if existing.Equal(name) {

std/sync/snapshot_node_history.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ type SnapshotNodeHistory struct {
4444

4545
// In Repo mode, all snapshots are fetched automtically for persistence.
4646
IsRepo bool
47-
// IgnoreValidity ignores validity period in the validation chain
48-
IgnoreValidity optional.Optional[bool]
47+
// UseSignatureTime checks validity period using signature time
48+
UseSignatureTime optional.Optional[bool]
4949
// repoKnown is the known snapshot sequence number.
5050
repoKnown SvMap[uint64]
5151

@@ -162,8 +162,8 @@ func (s *SnapshotNodeHistory) idxName(node enc.Name, boot uint64) enc.Name {
162162
// fetchIndex fetches the latest index for a remote node.
163163
func (s *SnapshotNodeHistory) fetchIndex(node enc.Name, boot uint64, known uint64) {
164164
s.Client.ConsumeExt(ndn.ConsumeExtArgs{
165-
Name: s.idxName(node, boot),
166-
IgnoreValidity: s.IgnoreValidity,
165+
Name: s.idxName(node, boot),
166+
UseSignatureTime: s.UseSignatureTime,
167167
Callback: func(cstate ndn.ConsumeState) {
168168
go s.handleIndex(node, boot, known, cstate)
169169
},
@@ -210,9 +210,9 @@ func (s *SnapshotNodeHistory) handleIndex(node enc.Name, boot uint64, known uint
210210

211211
snapName := s.snapName(node, boot).WithVersion(seqNo)
212212
s.Client.ConsumeExt(ndn.ConsumeExtArgs{
213-
Name: snapName,
214-
IgnoreValidity: s.IgnoreValidity,
215-
Callback: func(cstate ndn.ConsumeState) { snapC <- cstate },
213+
Name: snapName,
214+
UseSignatureTime: s.UseSignatureTime,
215+
Callback: func(cstate ndn.ConsumeState) { snapC <- cstate },
216216
})
217217

218218
scstate := <-snapC

0 commit comments

Comments
 (0)