How to configure SSL using Echo?

Hello Gophers,

I’m coming in now in the world Go, my knowledge is practically nil when it comes to SSL / TLS and Echo, I’m trying to apply the example (https://echo.labstack.com/cookbook/auto-tls), but on the console I get this output: “echo: http: TLS handshake error from 127.0.0.1:55095: tls: first record does not look like a TLS handshake”

I just copied the example and pasted it into my main.go file, is there any extra configuration? Could someone indicate support material?

Where do I point to the “.crt” and “.key” files?

Thank you all
Marcelo

The recipe you are following is to obtain TLS certificate from https://letsencrypt.org and use it in the configuration. You need to make sure that your server is publicly accessible via a valid domain on port 443; which it uses to verify the domain. Other option is obtain TLS certificate from a CA and using it with Echo#StartTLS() function.

Hello vishr,

Many thanks for the clarification.

At this point I would like just a simple test (localhost), I was successful using the example below, how can I apply this step with Echo? Is this allowed?

http.HandleFunc("/test", handler)
log.Println(“Go to https://localhost:10443/ or https://127.0.0.1:10443”)
err := http.ListenAndServeTLS(":443", “cert.pem”, “key.pem”, nil)
if err != nil {
  log.Println(err)
}

I’m sorry!!!

Now it’s clear, there is the “StartTLS” method where I can pass “cert.pem”, “key.pem” and get the same effect.

Many thanks vishr