2

I have build a Go server using Echo framework, i get TLS certificades and a domain name, but when i try a request i get the message "Client sent an HTTP request to an HTTPS server." and when i try acces the server from the IP address of the EC2 using the port 443, it says that the connection is not secure:

enter image description here

And when i change the server to the port 80 to acces through the domain name, i get the following error:

enter image description here

I'm starting the server using the StartTLS func

e.Logger.Fatal(e.StartTLS(":80", "/etc/letsencrypt/live/anltcsprod.enrtt.com/fullchain.pem", "/etc/letsencrypt/live/anltcsprod.enrtt.com/privkey.pem"))

Is it something wrong with my domain or certificade?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Jorge Barraza Z
  • 171
  • 3
  • 9
  • 1
    If your certificate has the domain name, then you have to access the site using the domain name. If you access using port 80, the default protocol is http, not https. Use port 443, and access using domain name – Burak Serdar Sep 23 '20 at 04:24
  • @BurakSerdar Thanks, now i use it at port 443 but still i get the ERR_CONNECTION_REFUSED when trying to connect using the domain :( – Jorge Barraza Z Sep 23 '20 at 19:44
  • 1
    Are you connecting to `https://domain`, or `http://domain`? If you are doing http, then it will go to :80. – Burak Serdar Sep 23 '20 at 19:59
  • True! it works! my bad haha i assumed that writing the domain in the browser by default was HTTPS but when i write all the address using the HTTPS it worked! Thank you @BurakSerdar – Jorge Barraza Z Sep 23 '20 at 20:03

2 Answers2

4

Port 80, by default, communicates over HTTP. 443 is reserved for HTTPS traffic. Assuming nothing else is wrong, you should be able to simply change your e.StartTLS() to this:

e.Logger.Fatal(e.StartTLS(":443", "/etc/letsencrypt/live/anltcsprod.enrtt.com/fullchain.pem", "/etc/letsencrypt/live/anltcsprod.enrtt.com/privkey.pem"))
lossdev
  • 101
  • 4
0

For example localhost:4000

Instead use https://localhost:4000

jeffasante
  • 2,549
  • 2
  • 8
  • 8