-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssl.go
50 lines (43 loc) · 1.21 KB
/
ssl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"crypto/tls"
"log"
"net/http"
)
func redirectSSL(rsp http.ResponseWriter, req *http.Request) {
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
target += "?" + req.URL.RawQuery
}
http.Redirect(rsp, req, target,
http.StatusTemporaryRedirect)
}
func buildSSLServer() http.Server {
cfg := &tls.Config{}
// remove the following line and configure the certificates
log.Fatal("Please configure uberproxy SSL certificates at infra/uberproxy/ssl.go")
/*
Example:
var err error
cfg.Certificates = make([]tls.Certificate, 3)
cfg.Certificates[0], err = tls.LoadX509KeyPair(os.Args[2]+"/geegle.org.pem", os.Args[2]+"/geegle.org.key")
if err != nil {
log.Fatal(err)
}
cfg.Certificates[1], err = tls.LoadX509KeyPair(os.Args[2]+"/corp.geegle.org.pem", os.Args[2]+"/corp.geegle.org.key")
if err != nil {
log.Fatal(err)
}
cfg.Certificates[2], err = tls.LoadX509KeyPair(os.Args[2]+"/apps.geegle.org.pem", os.Args[2]+"/apps.geegle.org.key")
if err != nil {
log.Fatal(err)
}
*/
cfg.BuildNameToCertificate()
server := http.Server{
Addr: ":443",
Handler: WrapHandlerWithLogging(http.HandlerFunc(handleUP)),
TLSConfig: cfg,
}
return server
}