Skip to content

Add Go NDNCERT CA server and enhance status reporting - #235

Closed
markverick wants to merge 11 commits into
mainfrom
testbed-staging
Closed

markverick wants to merge 11 commits into
mainfrom
testbed-staging

Conversation

@markverick

Copy link
Copy Markdown
Collaborator

This pull request introduces a comprehensive implementation of NDNCERT server-side challenges for certificate issuance, including DNS-01 and email-based verification, along with extensive unit tests and configuration examples. It also corrects a metrics bug and updates documentation to reflect new features.

NDNCERT Challenge Implementation:

  • Added a server-side DNS-01 challenge handler (ChallengeDnsHandler) that verifies domain ownership by requiring a TXT record with a random token, including support for mock/testing and robust error handling.
  • Implemented a robust email challenge handler (ChallengeEmailHandler) and SMTP sender, supporting secure code generation, delivery, and validation, with replay/attempt limits and expiration.
  • Provided sample configuration for NDNCERT CA, including supported challenges and SMTP settings (ca.conf.sample).

Testing and Quality Assurance:

  • Added comprehensive unit tests for both DNS and email challenges, covering success, failure, edge cases, and error handling. [1] [2]
  • Added a unit test for certificate request policy validation and certificate storage.

Documentation:

  • Updated documentation to describe new ndnd fw status-report and status-server commands, clarifying their output and behavior.

Bug Fix:

  • Fixed a bug in face statistics reporting where NOutBytes was incorrectly set to the value of NInBytes instead of NOutBytes.

Build and Security:

  • Updated the Dockerfile to include system CA certificates, enabling secure outbound TLS connections in the container.

@markverick

Copy link
Copy Markdown
Collaborator Author

Draft until I tested on challenges

Comment thread tools/nfdc/nfdc_status_report.go Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved authorization, malformed-input, replay, and synchronization issues compromise CA security and reliability.

7 open issues
1 file not reviewed
  • std/security/ndncert/tlv/zz_generated.go: Generated file
What changed in this PR

Adds an NDNCERT certificate authority to NDNd and expands forwarder status reporting.

Changes:

  • Implements CA issuance, DNS/email challenges, configuration, and tests.
  • Adds XML status reports and an HTTP HTML dashboard.
  • Corrects outbound-byte metrics and includes container TLS trust certificates.
File Description
tools/​sec/​cmd_sec.go Registers the CA command.
tools/​sec/​cert_server.go Configures and runs the CA.
tools/​nfdc/​nfdc.go Registers status commands.
tools/​nfdc/​nfdc_status_server.go Serves the HTML dashboard.
tools/​nfdc/​nfdc_status_server_test.go Tests stylesheet delivery.
tools/​nfdc/​nfdc_status_report.go Collects and encodes status.
tools/​nfdc/​nfdc_status_report_test.go Tests mappings and rendering.
tools/​nfdc/​nfdc_dataset.go Adds single-packet status fetching.
tools/​nfdc/​ndnd-status.xsl Styles XML reports.
tools/​nfdc/​ndnd-status.html Defines the HTML dashboard.
std/​security/​signer/​validate_test.go Tests Interest signature validation.
std/​security/​signer/​validate_data.go Shares Data/Interest signature validation.
std/​security/​ndncert/​tlv/​zz_generated.go Encodes the optional suffix limit.
std/​security/​ndncert/​tlv/​definitions.go Defines the profile suffix limit.
std/​security/​ndncert/​server/​storage.go Stores requests and removes expired entries.
std/​security/​ndncert/​server/​state.go Tracks issuance and challenge state.
std/​security/​ndncert/​server/​config.go Loads CA and SMTP configuration.
std/​security/​ndncert/​server/​config_test.go Tests configuration and naming helpers.
std/​security/​ndncert/​server/​challenge_email.go Implements email verification and SMTP delivery.
std/​security/​ndncert/​server/​challenge_email_test.go Tests email challenge behavior.
std/​security/​ndncert/​server/​challenge_dns.go Implements DNS TXT verification.
std/​security/​ndncert/​server/​challenge_dns_test.go Exercises DNS challenge paths.
std/​security/​ndncert/​server/​ca.go Implements CA protocol and issuance.
std/​security/​ndncert/​server/​ca_policy_test.go Tests request policy and certificate storage.
std/​examples/​ndncert/​ca.conf.sample Provides sample CA configuration.
fw/​mgmt/​face.go Corrects outbound-byte reporting.
docs/​fw-control.md Documents status commands.
Dockerfile Includes TLS trust certificates.

Review effort: Balanced

Comment on lines +578 to +580
if state.Status == StatusSuccess {
fmt.Printf("INFO: challenge completed successfully, issuing cert\n")
cert, err := ca.issueCertificate(state)
Comment thread std/security/ndncert/server/ca.go Outdated
Comment on lines +740 to +741
var aeadMsg ndncert.AeadMessage
aeadMsg.FromTLV(cipherMsg)
Comment on lines +743 to +745
plaintext, err := ndncert.AeadDecrypt(state.AesKey, aeadMsg, state.RequestID)
if err != nil {
return "", nil, fmt.Errorf("failed to decrypt: %w", err)
"ca-prefix": "/example",
"ca-info": "An example NDNCERT CA",
"max-validity-period": "1296000",
"supported-challenges": [
}

chPrefix := base.Append(enc.NewGenericComponent("CHALLENGE"))
if err := ca.engine.AttachHandler(chPrefix, ca.onChallenge); err != nil {
Comment on lines +75 to +86
if err != nil {
return retry, "wrong-record", nil
}

for _, r := range records {
if strings.TrimSpace(strings.Trim(r, "\"")) == expected {
state.Status = StatusSuccess
return nil, "", nil
}
}

return retry, "wrong-record", nil
state.SetChallengeStateValue(emailCodeHashKey, hashEmailCode(salt, code))
state.Status = StatusChallenge
state.UpdatedAt = time.Now()
state.ExpiresAt = state.UpdatedAt.Add(emailCodeLifetime)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Go Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 2cb9dff Previous: d37de74 Ratio
BenchmarkDataEncodeMedium 652.7 ns/op 744 B/op 9 allocs/op 326.3 ns/op 744 B/op 9 allocs/op 2.00
BenchmarkDataEncodeMedium - ns/op 652.7 ns/op 326.3 ns/op 2.00
BenchmarkDataEncodeMediumLongName 1026 ns/op 1032 B/op 9 allocs/op 426.8 ns/op 1032 B/op 9 allocs/op 2.40
BenchmarkDataEncodeMediumLongName - ns/op 1026 ns/op 426.8 ns/op 2.40

This comment was automatically generated by workflow using github-action-benchmark.

CC: @pulsejet

@yoursunny yoursunny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see, Copilot flagged most issues already reported in #201.
You should fix #201 first before adding new features.

@markverick

Copy link
Copy Markdown
Collaborator Author

Split to #239, #240 , #242

@markverick markverick closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants