Skip to content

Commit 27cfd3c

Browse files
wangjq4214gabycoderabbitai[bot]
authored
🔥 feat: Add support for AutoTLS / ACME (#3201)
* feat: add a simple support for app.Listen * fix: fix the nil access error * chore: add test case for simple tls * fix: align the struct * chore: change the test case can't passed and not chack the file yet * fix: use TLS1.2 min * Fix lint issues * Fix call to os.MkdirTemp * Fix test check order * Update unit-tests for ACME * Update docs * Fix identation of whats_new examples * More updates to docs * Remove ACME tests. Add check for tlsConfig * Add ACME section to whats_new docs * Update docs/whats_new.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update fiber.md * Update whats_new.md --------- Co-authored-by: Juan Calderon-Perez <[email protected]> Co-authored-by: Juan Calderon-Perez <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 70a06c5 commit 27cfd3c

File tree

5 files changed

+264
-211
lines changed

5 files changed

+264
-211
lines changed

docs/api/fiber.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ app.Listen(":8080", fiber.ListenConfig{
114114
| <Reference id="listeneraddrfunc">ListenerAddrFunc</Reference> | `func(addr net.Addr)` | Allows accessing and customizing `net.Listener`. | `nil` |
115115
| <Reference id="listenernetwork">ListenerNetwork</Reference> | `string` | Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only). WARNING: When prefork is set to true, only "tcp4" and "tcp6" can be chosen. | `tcp4` |
116116
| <Reference id="onshutdownerror">OnShutdownError</Reference> | `func(err error)` | Allows to customize error behavior when gracefully shutting down the server by given signal. Prints error with `log.Fatalf()` | `nil` |
117-
| <Reference id="onshutdownsuccess">OnShutdownSuccess</Reference> | `func()` | Allows customizing success behavior when gracefully shutting down the server by given signal. | `nil` |
117+
| <Reference id="onshutdownsuccess">OnShutdownSuccess</Reference> | `func()` | Allows customizing success behavior when gracefully shutting down the server by given signal. | `nil` |
118118
| <Reference id="tlsconfigfunc">TLSConfigFunc</Reference> | `func(tlsConfig *tls.Config)` | Allows customizing `tls.Config` as you want. | `nil` |
119+
| <Reference id="autocertmanager">AutoCertManager</Reference> | `func(tlsConfig *tls.Config)` | Manages TLS certificates automatically using the ACME protocol. Enables integration with Let's Encrypt or other ACME-compatible providers. | `nil` |
119120

120121
### Listen
121122

@@ -166,6 +167,25 @@ app.Listen(":443", fiber.ListenConfig{CertClientFile: "./ca-chain-cert.pem"})
166167
app.Listen(":443", fiber.ListenConfig{CertFile: "./cert.pem", CertKeyFile: "./cert.key", CertClientFile: "./ca-chain-cert.pem"})
167168
```
168169

170+
#### TLS AutoCert support (ACME / Let's Encrypt)
171+
172+
Provides automatic access to certificates management from Let's Encrypt and any other ACME-based providers.
173+
174+
```go title="Examples"
175+
// Certificate manager
176+
certManager := &autocert.Manager{
177+
Prompt: autocert.AcceptTOS,
178+
// Replace with your domain name
179+
HostPolicy: autocert.HostWhitelist("example.com"),
180+
// Folder to store the certificates
181+
Cache: autocert.DirCache("./certs"),
182+
}
183+
184+
app.Listen(":444", fiber.ListenConfig{
185+
AutoCertManager: certManager,
186+
})
187+
```
188+
169189
### Listener
170190

171191
You can pass your own [`net.Listener`](https://pkg.go.dev/net/#Listener) using the `Listener` method. This method can be used to enable **TLS/HTTPS** with a custom tls.Config.

0 commit comments

Comments
 (0)