]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: add optional Server.TLSConfig field
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 20 Feb 2012 23:24:15 +0000 (10:24 +1100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 20 Feb 2012 23:24:15 +0000 (10:24 +1100)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5688047

src/pkg/net/http/server.go

index e715c73cb6e9586d1757f4f84e8f97546185130a..fa0df54a236c2dfef8b9ddc99638e1e1b8fcac30 100644 (file)
@@ -12,7 +12,6 @@ package http
 import (
        "bufio"
        "bytes"
-       "crypto/rand"
        "crypto/tls"
        "errors"
        "fmt"
@@ -985,6 +984,7 @@ type Server struct {
        ReadTimeout    time.Duration // maximum duration before timing out read of the request
        WriteTimeout   time.Duration // maximum duration before timing out write of the response
        MaxHeaderBytes int           // maximum size of request headers, DefaultMaxHeaderBytes if 0
+       TLSConfig      *tls.Config   // optional TLS config, used by ListenAndServeTLS
 }
 
 // ListenAndServe listens on the TCP network address srv.Addr and then
@@ -1121,9 +1121,12 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error {
        if addr == "" {
                addr = ":https"
        }
-       config := &tls.Config{
-               Rand:       rand.Reader,
-               NextProtos: []string{"http/1.1"},
+       config := &tls.Config{}
+       if srv.TLSConfig != nil {
+               *config = *srv.TLSConfig
+       }
+       if config.NextProtos == nil {
+               config.NextProtos = []string{"http/1.1"}
        }
 
        var err error