diff --git a/scripts/tests.sh b/scripts/tests.sh index fbc2388a..85fe3807 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -60,6 +60,7 @@ docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-s # check bootstrapping log docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com: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 my-admin@example.com: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 diff --git a/sztp-agent/pkg/secureagent/agent.go b/sztp-agent/pkg/secureagent/agent.go index 20114c41..5aefa247 100644 --- a/sztp-agent/pkg/secureagent/agent.go +++ b/sztp-agent/pkg/secureagent/agent.go @@ -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"` } diff --git a/sztp-agent/pkg/secureagent/agent_test.go b/sztp-agent/pkg/secureagent/agent_test.go index 152b140d..35b1400d 100644 --- a/sztp-agent/pkg/secureagent/agent_test.go +++ b/sztp-agent/pkg/secureagent/agent_test.go @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/sztp-agent/pkg/secureagent/daemon.go b/sztp-agent/pkg/secureagent/daemon.go index 6159da08..9a91a609 100644 --- a/sztp-agent/pkg/secureagent/daemon.go +++ b/sztp-agent/pkg/secureagent/daemon.go @@ -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"`