You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fiber version/commit
v2.32.0 Issue description
I copied example "autocert" but it is not working (Can't establish a connection with site. 127.0.0.1 refused to connect.) Expected behavior
Steps to reproduce
Code snippet
package main
import (
"crypto/tls""log""github.com/gofiber/fiber/v2""golang.org/x/crypto/acme/autocert"
)
funcmain() {
// Fiber instanceapp:=fiber.New()
// Routesapp.Get("/", func(c*fiber.Ctx) error {
returnc.SendString("This is a secure server 馃懏")
})
// Let鈥檚 Encrypt has rate limits: https://letsencrypt.org/docs/rate-limits/// It's recommended to use it's staging environment to test the code:// https://letsencrypt.org/docs/staging-environment/// Certificate managerm:=&autocert.Manager{
Prompt: autocert.AcceptTOS,
// Replace with your domainHostPolicy: autocert.HostWhitelist("example.com"),
// Folder to store the certificatesCache: autocert.DirCache("./certs"),
}
// TLS Configcfg:=&tls.Config{
// Get Certificate from Let's EncryptGetCertificate: m.GetCertificate,
// By default NextProtos contains the "h2"// This has to be removed since Fasthttp does not support HTTP/2// Or it will cause a flood of PRI method logs// http://webconcepts.info/concepts/http-method/PRINextProtos: []string{
"http/1.1", "acme-tls/1",
},
}
ln, err:=tls.Listen("tcp", ":443", cfg)
iferr!=nil {
panic(err)
}
// Start serverlog.Fatal(app.Listener(ln))
}
The text was updated successfully, but these errors were encountered:
where did you test the code ? on your local development environment ? or as described in the comments on your staging system which is accessible from outside ?
Thank you for your comment, it helped me figure out the problem.
This code actually shoudnt work because autocert cant generate cert for localhost
The solution: generate certificate by yourself, for example with mkcert
(Forgot about it, because I always used autocert with a domain targeting to localhost)
Fiber version/commit
v2.32.0
Issue description
I copied example "autocert" but it is not working (Can't establish a connection with site. 127.0.0.1 refused to connect.)
Expected behavior
Steps to reproduce
Code snippet
The text was updated successfully, but these errors were encountered: