Skip to content

Commit

Permalink
feat: WSClient mtls
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
  • Loading branch information
EnriqueL8 committed May 4, 2023
1 parent 658a7e2 commit dc45c07
Show file tree
Hide file tree
Showing 9 changed files with 569 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/hyperledger/firefly-common v1.2.8
github.com/hyperledger/firefly-common v1.2.10
github.com/hyperledger/firefly-signer v1.1.5
github.com/jarcoal/httpmock v1.2.0
github.com/karlseguin/ccache v2.0.3+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,8 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hyperledger/firefly-common v1.2.8 h1:tPHgjGzQnPRXl77qHQd+dieu6N62NFEWhoGW7sn9u6U=
github.com/hyperledger/firefly-common v1.2.8/go.mod h1:q6uawjzWAFekIMFb0t9EWpJQQvjvl2CFBikk6++8Woc=
github.com/hyperledger/firefly-common v1.2.10 h1:im+GPaTnv764WmNvmtFFXz7+wx2IXg58Pf8AtDapM5o=
github.com/hyperledger/firefly-common v1.2.10/go.mod h1:kSAawo5is7RKWh3e9PMdWuR/OitfHAaAWVSK6V4lX80=
github.com/hyperledger/firefly-signer v1.1.5 h1:kCHe4O3tmYaMYf1hXrG40sIlpiGfOICmNNAcuMH5+jQ=
github.com/hyperledger/firefly-signer v1.1.5/go.mod h1:XZP8ZXUZJSAPB6WUSM9RqRdpjnjm6Jsn0784WM4IKug=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
Expand Down
536 changes: 536 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion internal/blockchain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ func (e *Ethereum) Init(ctx context.Context, cancelCtx context.CancelFunc, conf
e.prefixShort = ethconnectConf.GetString(EthconnectPrefixShort)
e.prefixLong = ethconnectConf.GetString(EthconnectPrefixLong)

wsConfig := wsclient.GenerateConfig(ethconnectConf)
wsConfig, err := wsclient.GenerateConfig(ctx, ethconnectConf)
if err != nil {
return err
}

if wsConfig.WSKeyPath == "" {
wsConfig.WSKeyPath = "/ws"
}
Expand Down
7 changes: 6 additions & 1 deletion internal/blockchain/fabric/fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,15 @@ func (f *Fabric) Init(ctx context.Context, cancelCtx context.CancelFunc, conf co
f.prefixShort = fabconnectConf.GetString(FabconnectPrefixShort)
f.prefixLong = fabconnectConf.GetString(FabconnectPrefixLong)

wsConfig := wsclient.GenerateConfig(fabconnectConf)
wsConfig, err := wsclient.GenerateConfig(ctx, fabconnectConf)
if err != nil {
return err
}

if wsConfig.WSKeyPath == "" {
wsConfig.WSKeyPath = "/ws"
}

f.wsconn, err = wsclient.New(f.ctx, wsConfig, nil, f.afterConnect)
if err != nil {
return err
Expand Down
9 changes: 8 additions & 1 deletion internal/dataexchange/ffdx/ffdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ func (h *FFDX) Init(ctx context.Context, cancelCtx context.CancelFunc, config co
Factor: config.GetFloat64(DataExchangeRetryFactor),
}

wsConfig := wsclient.GenerateConfig(config)
wsConfig, err := wsclient.GenerateConfig(ctx, config)
if err != nil {
return err
}

if wsConfig.WSKeyPath == "" {
wsConfig.WSKeyPath = "/ws"
}

h.wsconn, err = wsclient.New(ctx, wsConfig, h.beforeConnect, nil)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/events/websockets/websockets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ func newTestWebsockets(t *testing.T, cbs *eventsmocks.Callbacks, authorizer core
qs = fmt.Sprintf("?%s", strings.Join(queryParams, "&"))
}
clientConfig.Set(ffresty.HTTPConfigURL, fmt.Sprintf("http://%s%s", svr.Listener.Addr(), qs))
wsConfig := wsclient.GenerateConfig(clientConfig)
wsConfig, err := wsclient.GenerateConfig(ctx, clientConfig)
assert.NoError(t, err)

wsc, err := wsclient.New(ctx, wsConfig, nil, nil)
wsc, err = wsclient.New(ctx, wsConfig, nil, nil)
assert.NoError(t, err)
err = wsc.Connect()
assert.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions internal/spievents/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ func newTestSPIEventsManager(t *testing.T) (ae *adminEventManager, ws *webSocket
clientConfig := config.RootSection("ut.wsclient")
wsclient.InitConfig(clientConfig)
clientConfig.Set(ffresty.HTTPConfigURL, fmt.Sprintf("http://%s", svr.Listener.Addr()))
wsConfig := wsclient.GenerateConfig(clientConfig)
wsConfig, err := wsclient.GenerateConfig(context.Background(), clientConfig)
assert.NoError(t, err)

wsc, err := wsclient.New(ae.ctx, wsConfig, nil, nil)
wsc, err = wsclient.New(ae.ctx, wsConfig, nil, nil)
assert.NoError(t, err)
err = wsc.Connect()
assert.NoError(t, err)
Expand Down
6 changes: 5 additions & 1 deletion internal/tokens/fftokens/fftokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ func (ft *FFTokens) Init(ctx context.Context, cancelCtx context.CancelFunc, name
return err
}

wsConfig := wsclient.GenerateConfig(config)
wsConfig, err := wsclient.GenerateConfig(ctx, config)
if err != nil {
return err
}

if wsConfig.WSKeyPath == "" {
wsConfig.WSKeyPath = "/api/ws"
}
Expand Down

0 comments on commit dc45c07

Please sign in to comment.