Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to listen with TLS #419

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/archivista/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ func main() {
ReadTimeout: time.Duration(archivistaService.Cfg.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(archivistaService.Cfg.WriteTimeout) * time.Second,
}

go func() {
if err := srv.Serve(listener); err != nil {
logrus.Fatalf("unable to start http server: %+v", err)
if archivistaService.Cfg.EnableTLS {
if err := srv.ListenAndServeTLS(archivistaService.Cfg.TLSCert, archivistaService.Cfg.TLSKey); err != nil {
logrus.Fatalf("unable to start http serveR: %+v", err)
}
} else {
if err := srv.Serve(listener); err != nil {
logrus.Fatalf("unable to start http server: %+v", err)
}
}
}()

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ type Config struct {
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
CORSAllowOrigins []string `default:"" desc:"Comma separated list of origins to allow CORS requests from" split_words:"true"`

EnableTLS bool `default:"FALSE" desc:"Enables TLS on the Archivista server" split_words:"true"`
TLSCert string `default:"" desc:"Path to the file containing the TLS Certificate" split_words:"true"`
TLSKey string `default:"" desc:"Path to the file containing the TLS Key" split_words:"true"`

EnableSPIFFE bool `default:"TRUE" desc:"*** Enable SPIFFE support" split_words:"true"`
SPIFFEAddress string `default:"unix:///tmp/spire-agent/public/api.sock" desc:"SPIFFE server address" split_words:"true"`
SPIFFETrustedServerId string `default:"" desc:"Trusted SPIFFE server ID; defaults to any" split_words:"true"`
Expand Down
Loading