Skip to content

Commit

Permalink
Merge pull request #83 from kaleido-io/fftmClientTLS
Browse files Browse the repository at this point in the history
add tls support for FFMT client to that evmconnect client mode can use it
  • Loading branch information
nguyer authored May 31, 2023
2 parents b14c2cf + fad11bc commit be4cafd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"

"github.com/hyperledger/firefly-common/pkg/config"
"github.com/hyperledger/firefly-common/pkg/fftls"
"github.com/hyperledger/firefly-common/pkg/httpserver"
"github.com/hyperledger/firefly-transaction-manager/internal/apiclient"
"github.com/hyperledger/firefly-transaction-manager/internal/tmconfig"
Expand All @@ -31,6 +32,11 @@ var url string
var nameRegex string
var ignoreNotFound bool

var tlsEnabled bool
var caFile string
var certFile string
var keyFile string

func ClientCommand() *cobra.Command {
return buildClientCommand(createClient)
}
Expand All @@ -45,6 +51,11 @@ func buildClientCommand(clientFactory func() (apiclient.FFTMClient, error)) *cob
clientCmd.PersistentFlags().BoolVarP(&ignoreNotFound, "ignore-not-found", "", false, "Does not return an error if the resource is not found. Useful for idempotent delete functions.")
clientCmd.PersistentFlags().StringVarP(&url, "url", "", defaultURL, "The URL of the blockchain connector")

clientCmd.PersistentFlags().BoolVarP(&tlsEnabled, "tls", "", false, "Enable TLS on client")
clientCmd.PersistentFlags().StringVarP(&caFile, "cacert", "", "", "The tls CA cert file")
clientCmd.PersistentFlags().StringVarP(&certFile, "cert", "", "", "The tls cert file")
clientCmd.PersistentFlags().StringVarP(&keyFile, "key", "", "", "The tls key file")

clientCmd.AddCommand(clientEventStreamsCommand(clientFactory))
clientCmd.AddCommand(clientListenersCommand(clientFactory))

Expand All @@ -57,6 +68,19 @@ func createClient() (apiclient.FFTMClient, error) {
if url != "" {
cfg.Set("url", url)
}
if tlsEnabled {
tlsConf := cfg.SubSection("tls")
tlsConf.Set(fftls.HTTPConfTLSEnabled, true)
if caFile != "" {
tlsConf.Set(fftls.HTTPConfTLSCAFile, caFile)
}
if certFile != "" {
tlsConf.Set(fftls.HTTPConfTLSCertFile, certFile)
}
if keyFile != "" {
tlsConf.Set(fftls.HTTPConfTLSKeyFile, keyFile)
}
}
return apiclient.NewFFTMClient(context.Background(), cfg)
}

Expand Down

0 comments on commit be4cafd

Please sign in to comment.