Comments (7)
FYI - from valyala/fasthttp "I have pushed a fix. I'll tag a release next week probably."
from fiber.
Pls share the code for outputSerialFromContext
And the error message
from fiber.
from fiber.
You need to make a copy https://docs.gofiber.io/#zero-allocation
from fiber.
from fiber.
from fiber.
here's a small example that demonstrates the bug:
package main
import (
"crypto"
"crypto/tls"
"fmt"
"os"
"github.com/gofiber/fiber/v2"
//"golang.org/x/crypto/pkcs12"
"github.com/gofiber/fiber/v2/log"
"github.com/gofiber/fiber/v2/middleware/logger"
"software.sslmate.com/src/go-pkcs12"
)
func initFiberApp() *fiber.App {
app := fiber.New()
app.Server().MaxConnsPerIP = 1
app.Use(logger.New(logger.Config{
DisableColors: false,
Format: "${date} ${time} ${ip} ${status} - ${method} ${path} ${yellow}SerialNo[${serialNumber}]\n",
TimeFormat: "2006-01-02 15:04:05",
TimeZone: "Local",
CustomTags: map[string]logger.LogFunc{
"serialNumber": func(output logger.Buffer, c *fiber.Ctx, data *logger.Data, extraParam string) (int, error) {
return output.WriteString(c.Context().TLSConnectionState().PeerCertificates[0].SerialNumber.String())
},
},
}))
app.Get("/", func(c *fiber.Ctx) error {
if c.Context().TLSConnectionState() != nil && len(c.Context().TLSConnectionState().PeerCertificates) == 0 {
log.Warn("no peer certs")
} else {
log.Info("peer certs exist")
}
return c.SendString(fmt.Sprintf("This page is being served over TLS using a PKCS12 store type: %s",
c.Context().TLSConnectionState().PeerCertificates[0].SerialNumber.String()))
})
return app
}
func initTLSConfig(path string, password string) (*tls.Certificate, error) {
pkcs12Data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
key, cert, _, err := pkcs12.DecodeChain(pkcs12Data, password)
if err != nil {
return nil, err
}
tlsCert := tls.Certificate{
Certificate: [][]byte{cert.Raw},
PrivateKey: key.(crypto.PrivateKey),
Leaf: cert,
}
return &tlsCert, nil
}
func main() {
path := "./security/server.p12"
password := "foobar"
tlsCert, error := initTLSConfig(path, password)
if error != nil {
fmt.Printf("Unable to initialize TLS configuration object. Check your configuration and try again. Program will STOP: %s", error)
} else {
config := &tls.Config{
Certificates: []tls.Certificate{*tlsCert},
ClientAuth: tls.RequireAndVerifyClientCert,
}
app := initFiberApp()
ln, err := tls.Listen("tcp", ":5443", config)
if err != nil {
panic(err)
}
log.Fatal(app.Listener(ln))
}
}
if you set MaxConnsPerIP
> 0
you'll get a sigseg violation - the issue is in the worker pool implementation for fasthttps...
I think you can close this out and I should open it with their package...
from fiber.
Related Issues (20)
- π [docs]: Fix broken link in FAQ section HOT 1
- How to use Middleware handler HOT 3
- π€ [Question]: Why v3 has no option to DisableStartupMessage HOT 2
- π€ [Question]: upstream reply with long time HOT 8
- π€ [Question]: i get v3 docs are not exactly v3 docs HOT 1
- π [Proposal]: Re-introduce the DisableStartupMessage configuration option in Fiber v3 HOT 2
- π€ [Question]: How to disable logger middleware in some endpoints HOT 2
- π [Bug]: Prefork Not Working on Fiber v3 HOT 2
- π [Proposal]: shutdown procedure
- π [Bug]: incorrect routing when adding a default layout HOT 4
- π [Bug]: Middleware Monitor "CPU Usage" is a "static value". HOT 2
- π [Bug]: Appending handlers screws up routing HOT 2
- π€ [Question]: get param from path for proxy pass request HOT 1
- π [Bug]: Abort Signal HOT 5
- π€ [Question]: Enable DisableHeaderNormalizing config will occur wrong cors middleware behaviour HOT 11
- π€ [Question]: Question on ETag Docs HOT 1
- π€ [Question]: Does Fiber handle each request in different goroutines? HOT 2
- π [Feature] [v2]: Add a function to get the session expiry HOT 5
- π€ [Question]: Fiber http with Cloudflare ssl reverse leading to 525, SSL handshake failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.