Il seguente è il mio TLS backend:Golang ListenAndServeTLS restituisce i dati quando non si usa https nel browser
package main
import (
"fmt"
"net/http"
)
const (
PORT = ":8443"
PRIV_KEY = "./private_key"
PUBLIC_KEY = "./public_key"
)
func rootHander(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Nobody should read this.")
}
func main() {
http.HandleFunc("/", rootHander)
err := http.ListenAndServeTLS(PORT, PUBLIC_KEY, PRIV_KEY, nil)
if err != nil {
fmt.Printf("main(): %s\n", err)
}
}
Le chiavi vengono generati utilizzando queste due righe:
openssl genrsa -out private_key 2048
openssl req -new -x509 -key private_key -out public_key -days 365
Quando ho avviare il server TLS e visitare il sito con un browser (https://example.com:8443) Ottengo il risultato previsto, dopo ignorando il messaggio di avviso del browser:
Nobody should read this.
Finora tutto è bello.
Ora, quando indico il mio browser per http://example.com:8443 (notare che http viene utilizzato, non https) ottengo il seguente risultato Firfox (Chrome fa lo stesso, ma il download del sito):
Domanda: Perché c'è un punto interrogativo?
funziona https://groups.google.com/forum/#!topic/golang-nuts/ZtP5vPPeyHE anche per te ? – ddevienne