August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this section, we are going to implement a TLS server named TLSserver.go, which will be presented in four parts. This time, the HTTPS server will be better than the https.go server implemented in the previous section.
The first part of TLSserver.go is as follows:
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net/http"
)
var PORT = ":1443"
type handler struct {
}
The second part of TLSserver.go contains the following code:
func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("Hello world!\n"))
}
This is the handler function of the web server that handles all client connections.
The third part of TLSserver.go is as follows:
func main() { caCert, ...Read now
Unlock full access