mirror of
https://github.com/minio/minio.git
synced 2025-11-29 21:33:31 -05:00
Implement TLS server
$ ./minio --tls --cert <your_cert> --key <your_private_key> This patchset also provides crypto/x509 - which is a wrapper package to generate X509 certificates. This is necessary to provide certificates later through management console
This commit is contained in:
@@ -22,24 +22,39 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func Start(handler http.Handler, address string) (chan<- string, <-chan error) {
|
||||
type HttpServer struct {
|
||||
Address string
|
||||
TLS bool
|
||||
CertFile string
|
||||
KeyFile string
|
||||
}
|
||||
|
||||
func Start(handler http.Handler, srv HttpServer) (chan<- string, <-chan error) {
|
||||
ctrlChannel := make(chan string)
|
||||
errorChannel := make(chan error)
|
||||
go start(ctrlChannel, errorChannel, handler, address)
|
||||
go start(ctrlChannel, errorChannel, handler, srv)
|
||||
return ctrlChannel, errorChannel
|
||||
}
|
||||
|
||||
func start(ctrlChannel <-chan string, errorChannel chan<- error, router http.Handler, address string) {
|
||||
log.Println("Starting HTTP Server on " + address)
|
||||
func start(ctrlChannel <-chan string, errorChannel chan<- error, router http.Handler, srv HttpServer) {
|
||||
var err error
|
||||
|
||||
// Minio server config
|
||||
server := &http.Server{
|
||||
Addr: address,
|
||||
Addr: srv.Address,
|
||||
Handler: router,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
MaxHeaderBytes: 1 << 20,
|
||||
}
|
||||
err := server.ListenAndServe()
|
||||
log.Println("Starting HTTP Server on " + srv.Address)
|
||||
|
||||
if srv.TLS {
|
||||
server.TLSConfig = getDefaultTLSConfig()
|
||||
err = server.ListenAndServeTLS(srv.CertFile, srv.KeyFile)
|
||||
} else {
|
||||
err = server.ListenAndServe()
|
||||
}
|
||||
errorChannel <- err
|
||||
close(errorChannel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user