golang-tls icon indicating copy to clipboard operation
golang-tls copied to clipboard

http: TLS handshake error

Open mateors opened this issue 2 years ago • 0 comments

package main

import (
    // "fmt"
    // "io"
    "net/http"
    "log"
)

func HelloServer(w http.ResponseWriter, req *http.Request) {
    w.Header().Set("Content-Type", "text/plain")
    w.Write([]byte("This is an example server.\n"))
}

func main() {
    http.HandleFunc("/hello", HelloServer)
    err := http.ListenAndServeTLS(":443", "cert/server.crt", "cert/server.key", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err)
    }
}

the above code generate following error when request using curl -sL https://localhost:443

2023/10/16 07:44:15 http: TLS handshake error from 127.0.0.1:49428: local error: tls: bad record MAC

mateors avatar Oct 16 '23 01:10 mateors