diff options
| author | Berck Nash <berck@cloudflare.com> | 2022-03-14 17:22:52 -0600 |
|---|---|---|
| committer | Berck Nash <berck@cloudflare.com> | 2022-03-16 09:52:17 -0600 |
| commit | 9b14f0c81a9348ccb8a79ffcf9cdbc7033d00fac (patch) | |
| tree | 416bd650c36851ed7603c74bc86308a24f214221 /weed/command/volume.go | |
| parent | b5b97a4799e1929bb22d816aca450ea18f7ec08e (diff) | |
| download | seaweedfs-9b14f0c81a9348ccb8a79ffcf9cdbc7033d00fac.tar.xz seaweedfs-9b14f0c81a9348ccb8a79ffcf9cdbc7033d00fac.zip | |
Add mTLS support for both master and volume http server.
Diffstat (limited to 'weed/command/volume.go')
| -rw-r--r-- | weed/command/volume.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go index f3b36fcda..645c698b1 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -2,7 +2,6 @@ package command import ( "fmt" - "github.com/chrislusf/seaweedfs/weed/storage/types" "net/http" httppprof "net/http/pprof" "os" @@ -11,6 +10,8 @@ import ( "strings" "time" + "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/spf13/viper" "google.golang.org/grpc" @@ -24,7 +25,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" - "github.com/chrislusf/seaweedfs/weed/server" + weed_server "github.com/chrislusf/seaweedfs/weed/server" stats_collect "github.com/chrislusf/seaweedfs/weed/stats" "github.com/chrislusf/seaweedfs/weed/storage" "github.com/chrislusf/seaweedfs/weed/util" @@ -371,7 +372,14 @@ func (v VolumeServerOptions) startClusterHttpService(handler http.Handler) httpd StopTimeout: 30 * time.Second, CertFile: certFile, KeyFile: keyFile} - clusterHttpServer := httpDown.Serve(&http.Server{Handler: handler}, listener) + httpS := &http.Server{Handler: handler} + + if viper.GetString("https.volume.ca") != "" { + clientCertFile := viper.GetString("https.volume.ca") + httpS.TLSConfig = security.LoadClientTLSHTTP(clientCertFile) + } + + clusterHttpServer := httpDown.Serve(httpS, listener) go func() { if e := clusterHttpServer.Wait(); e != nil { glog.Fatalf("Volume server fail to serve: %v", e) |
