diff --git a/goKMS/kms/etsi20bordernode/etsi20bordernode_client.go b/goKMS/kms/etsi20bordernode/etsi20bordernode_client.go index f1cb2c2b3cbcd1e390f05ebcc37a104d76614788..3bb71c00b6a9b97221b58c876d6ad9b56306057d 100644 --- a/goKMS/kms/etsi20bordernode/etsi20bordernode_client.go +++ b/goKMS/kms/etsi20bordernode/etsi20bordernode_client.go @@ -3,6 +3,7 @@ package etsi20bordernode import ( "context" "crypto/tls" + "fmt" "net/http" log "github.com/sirupsen/logrus" @@ -25,7 +26,8 @@ func NewETSI20BorderNodeClient(exitID uuid.UUID, exitAddr string) *ETSI20BorderN } } -func (e *ETSI20BorderNodeClient) ETSI20ForwardExternal(initiatorSaeId uuid.UUID, targetSaeId uuid.UUID, keys []crypto.KSAKey) error { +// func (e *ETSI20BorderNodeClient) ETSI20ForwardExternal(initiatorSaeId uuid.UUID, targetSaeId uuid.UUID, keys []crypto.KSAKey) error. +func (e *ETSI20BorderNodeClient) ETSI20ForwardExternal(initiatorSaeId string, targetSaeId string, keys []crypto.KSAKey) error { // TODO: for demo only ackCallbackURL := "http://localhost:4545" @@ -43,13 +45,14 @@ func (e *ETSI20BorderNodeClient) ETSI20ForwardExternal(initiatorSaeId uuid.UUID, var targetSaeIds e20.TargetSaeIds - targetSaeIds = append(targetSaeIds, targetSaeId.String()) + //targetSaeIds = append(targetSaeIds, targetSaeId.String()) + targetSaeIds = append(targetSaeIds, targetSaeId) postBody := e20.ExtKeyContainer{ AckCallbackUrl: ackCallbackURL, ExtensionMandatory: nil, // not needed ExtensionOptional: nil, // not needed - InitiatorSaeId: initiatorSaeId.String(), + InitiatorSaeId: initiatorSaeId, Keys: e20Keys, TargetSaeIds: targetSaeIds, } @@ -65,13 +68,18 @@ func (e *ETSI20BorderNodeClient) ETSI20ForwardExternal(initiatorSaeId uuid.UUID, client, _ := e20.NewClientWithResponses(e.e20BNLocalExitHTTPAddress, clientHandler) ctx := context.Background() - log.Printf("(ETSI20ForwardExternal) Asking for key forwarding with PostExtKeys with BN %s, initSAEDID %s, targetSAEID %s", e.e20BNLocalExitHTTPAddress, initiatorSaeId.String(), targetSaeId) + log.Printf("(ETSI20ForwardExternal) Asking for key forwarding with PostExtKeys with BN %s, initSAEDID %s, targetSAEID %s", e.e20BNLocalExitHTTPAddress, initiatorSaeId, targetSaeId) postReponse, err := client.PostExtKeys(ctx, postBody) if err != nil { - log.Printf("Client PostExtKeys failed %s", err) + log.Printf("(ETSI20ForwardExternal) Client PostExtKeys Transport failed %s", err) return err } log.Printf("(ETSI20ForwardExternal) postResponse %s", postReponse.Status) + // Needs better error handling for HTTP responses and ETSI20 + if postReponse.StatusCode != 202 { + log.Printf("(ETSI20ForwardExternal) Client PostExtKeys failed with HTTP status %d %s", postReponse.StatusCode, postReponse.Status) + return fmt.Errorf("(ETSI20ForwardExternal) Client PostExtKeys failed with HTTP status %d %s", postReponse.StatusCode, postReponse.Status) + } return nil } diff --git a/goKMS/kms/kmsintercom.go b/goKMS/kms/kmsintercom.go index 4d2c70149548f3031b61fd0c08f0ec13f9d7844b..8aa74890183bdcc3cd1eeed7a11ef597dd1bec92 100644 --- a/goKMS/kms/kmsintercom.go +++ b/goKMS/kms/kmsintercom.go @@ -331,8 +331,12 @@ func (s *kmsTalkerServer) KeyDelivery(ctx context.Context, in *pb.KeyDeliveryReq idString, httpAString := s.kms.ETSI20BorderNodeServer.GetE20BNLocalExit() e20bnClient := e20bn.NewETSI20BorderNodeClient(idString, httpAString) + /* UUID based not for the demo initID, _ := uuid.Parse(in.GetE20InitatorSaeID()) targetID, _ := uuid.Parse(in.GetE20TargetSaeIDs()[0]) + err = e20bnClient.ETSI20ForwardExternal(initID, targetID, akmsKSAKeys) */ + initID := in.GetE20InitatorSaeID() + targetID := in.GetE20InitatorSaeID() err = e20bnClient.ETSI20ForwardExternal(initID, targetID, akmsKSAKeys) if err != nil { log.Errorf("(ETSI20 cannot forward to ETSI20 bordnernode %s due to %s", httpAString, err)