Commit c099925d authored by owlo's avatar owlo

TLS, TLS, T,L,S

parent 495ba078
No preview for this file type
......@@ -2,10 +2,12 @@ package main
import (
"bufio"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"math/rand"
"net/http"
"os"
......@@ -816,7 +818,7 @@ func main() {
// }
// })
// http.ListenAndServe(":8080", mux)
// http.ListenAndServe(":443", mux)
// }
mux.HandleFunc("/exampleposter", func(w http.ResponseWriter, req *http.Request) {
// Before any call to WriteHeader or Write, declare
......@@ -839,6 +841,31 @@ func main() {
validate(UID, object)
})
http.ListenAndServe(":8080", mux)
const prefix = "/home/twotonne/"
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
w.Write([]byte("This is an example server.\n"))
})
cfg := &tls.Config{
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
PreferServerCipherSuites: true,
CipherSuites: []uint16{
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
},
}
srv := &http.Server{
Addr: ":8080",
Handler: mux,
TLSConfig: cfg,
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0),
}
log.Fatal(srv.ListenAndServeTLS(prefix+"go/src/localtoast.net/localtoast/server.rsa.crt", prefix+"go/src/localtoast.net/localtoast/server.rsa.key"))
// http.ListenAndServeTLS(":443", prefix+"go/src/localtoast.net/localtoast/server.rsa.crt", prefix+"go/src/localtoast.net/localtoast/server.rsa.key", mux)
}
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment