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
Reduce the boilerplate of setting up AutoTLS / ACME by adding built-in support into Fiber. Similar to what Gin and Echo currently offer. We currently support this via a recipe, but we had users ask how to do this. Ideally we should integrate the code from the recipe into a new function under app similar to app.Listen() or app.Listener().
Wecurrentlyhavearecipefordoingthis:
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’s 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))
}
I've checked out gin to see how do they support this and it seems like they have a separate module to run everything smoothly according to the docs. Not sure if this is the same thing we want to support in here. Could you confirm or correct me if I'm wrong?
But yes, similar to what gin/echo/hertz and other frameworks are doing. But integrated instead of a separate module. Almost any user in production or with a server exposed to the internet will use ACME, may as well support it out of the box.
Feature Proposal Description
Reduce the boilerplate of setting up AutoTLS / ACME by adding built-in support into Fiber. Similar to what
Gin
andEcho
currently offer. We currently support this via a recipe, but we had users ask how to do this. Ideally we should integrate the code from the recipe into a new function underapp
similar toapp.Listen()
orapp.Listener()
.Alignment with Express API
N/a
HTTP RFC Standards Compliance
RFC 8555 - https://datatracker.ietf.org/doc/html/rfc8555/
API Stability
N/a
Feature Examples
Checklist:
The text was updated successfully, but these errors were encountered: