Skip to content

Commit

Permalink
fix: add trust-anchor-cert to progress
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jun 12, 2024
1 parent 2dcd78c commit 5461c97
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-s

# check bootstrapping log
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=my-serial-number/bootstrapping-log
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=my-serial-number/bootstrapping-log | grep -zqv ietf-restconf:errors

# parse the reply some more
jq -r .\"ietf-sztp-conveyed-info:onboarding-information\".\"configuration\" /tmp/post_rpc_fixed.json | base64 --decode
Expand Down
3 changes: 3 additions & 0 deletions sztp-agent/pkg/secureagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ type ProgressJSON struct {
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
} `json:"ietf-sztp-bootstrap-server:input"`
}

Expand Down
12 changes: 12 additions & 0 deletions sztp-agent/pkg/secureagent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,9 @@ func TestAgent_GetProgressJson(t *testing.T) {
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
}{
ProgressType: "test",
Message: "test",
Expand All @@ -909,6 +912,9 @@ func TestAgent_GetProgressJson(t *testing.T) {
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
}{
ProgressType: "test",
Message: "test",
Expand Down Expand Up @@ -980,6 +986,9 @@ func TestAgent_SetProgressJson(t *testing.T) {
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
}{
ProgressType: "test",
Message: "test",
Expand All @@ -997,6 +1006,9 @@ func TestAgent_SetProgressJson(t *testing.T) {
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
}{
ProgressType: "testNew",
Message: "testNew",
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (a *Agent) doReportProgress(s ProgressType) error {
if s == ProgressTypeBootstrapComplete {
// TODO: generate real key here
encodedKey := base64.StdEncoding.EncodeToString([]byte("mysshpass"))
p.IetfSztpBootstrapServerInput.TrustAnchorCerts.TrustAnchorCert = []string{encodedKey}
p.IetfSztpBootstrapServerInput.SSHHostKeys.SSHHostKey = []struct {
Algorithm string `json:"algorithm"`
KeyData string `json:"key-data"`
Expand Down

0 comments on commit 5461c97

Please sign in to comment.