Skip to content

Commit be4cafd

Browse files
authored
Merge pull request #83 from kaleido-io/fftmClientTLS
add tls support for FFMT client to that evmconnect client mode can use it
2 parents b14c2cf + fad11bc commit be4cafd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cmd/client.go

+24
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222

2323
"github.com/hyperledger/firefly-common/pkg/config"
24+
"github.com/hyperledger/firefly-common/pkg/fftls"
2425
"github.com/hyperledger/firefly-common/pkg/httpserver"
2526
"github.com/hyperledger/firefly-transaction-manager/internal/apiclient"
2627
"github.com/hyperledger/firefly-transaction-manager/internal/tmconfig"
@@ -31,6 +32,11 @@ var url string
3132
var nameRegex string
3233
var ignoreNotFound bool
3334

35+
var tlsEnabled bool
36+
var caFile string
37+
var certFile string
38+
var keyFile string
39+
3440
func ClientCommand() *cobra.Command {
3541
return buildClientCommand(createClient)
3642
}
@@ -45,6 +51,11 @@ func buildClientCommand(clientFactory func() (apiclient.FFTMClient, error)) *cob
4551
clientCmd.PersistentFlags().BoolVarP(&ignoreNotFound, "ignore-not-found", "", false, "Does not return an error if the resource is not found. Useful for idempotent delete functions.")
4652
clientCmd.PersistentFlags().StringVarP(&url, "url", "", defaultURL, "The URL of the blockchain connector")
4753

54+
clientCmd.PersistentFlags().BoolVarP(&tlsEnabled, "tls", "", false, "Enable TLS on client")
55+
clientCmd.PersistentFlags().StringVarP(&caFile, "cacert", "", "", "The tls CA cert file")
56+
clientCmd.PersistentFlags().StringVarP(&certFile, "cert", "", "", "The tls cert file")
57+
clientCmd.PersistentFlags().StringVarP(&keyFile, "key", "", "", "The tls key file")
58+
4859
clientCmd.AddCommand(clientEventStreamsCommand(clientFactory))
4960
clientCmd.AddCommand(clientListenersCommand(clientFactory))
5061

@@ -57,6 +68,19 @@ func createClient() (apiclient.FFTMClient, error) {
5768
if url != "" {
5869
cfg.Set("url", url)
5970
}
71+
if tlsEnabled {
72+
tlsConf := cfg.SubSection("tls")
73+
tlsConf.Set(fftls.HTTPConfTLSEnabled, true)
74+
if caFile != "" {
75+
tlsConf.Set(fftls.HTTPConfTLSCAFile, caFile)
76+
}
77+
if certFile != "" {
78+
tlsConf.Set(fftls.HTTPConfTLSCertFile, certFile)
79+
}
80+
if keyFile != "" {
81+
tlsConf.Set(fftls.HTTPConfTLSKeyFile, keyFile)
82+
}
83+
}
6084
return apiclient.NewFFTMClient(context.Background(), cfg)
6185
}
6286

0 commit comments

Comments
 (0)