-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (32 loc) · 702 Bytes
/
main.go
File metadata and controls
41 lines (32 loc) · 702 Bytes
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
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"github.com/shu-yusa/go-tls/tls13"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, TLS 1.3!")
}
func fullTLSServer() {
mux := http.NewServeMux()
mux.HandleFunc("/", handler)
// TLS 1.3
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS13,
PreferServerCipherSuites: true,
}
server := &http.Server{
Addr: ":https",
Handler: mux,
TLSConfig: tlsConfig,
}
log.Fatal(server.ListenAndServeTLS("server.crt", "server.key"))
}
func main() {
logger := log.New(log.Writer(), "", 0)
// logger := log.New(io.Discard, "", 0)
tls13.Server(logger)
// fullTLSServer()
}