Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤔 Ability to use tls through autocert? #200

Closed
Terisback opened this issue Mar 2, 2020 · 4 comments
Closed

🤔 Ability to use tls through autocert? #200

Terisback opened this issue Mar 2, 2020 · 4 comments

Comments

@Terisback
Copy link

Question description

I do not have certificate files, but have Let's Encrypt
What I need to host on https with tls?

@renanbastos93
Copy link
Member

renanbastos93 commented Mar 2, 2020

According to use inside FastHttp, I believe that you can be based on e.g. below:

I saw these two examples:
valyala/fasthttp#167
valyala/fasthttp#431

@Terisback
Copy link
Author

Tnx, I'll see tomorrow morning

@Fenny
Copy link
Member

Fenny commented Mar 2, 2020

Hi @Terisback v1.8.2 will support custom TLS configs

package main

import (
    "crypto/tls"
    "github.com/gofiber/fiber"
)

func main() {
	app := fiber.New()

	app.Get("/", func(c *fiber.Ctx) {
		c.Send(c.Protocol()) // => https
	})

	cer, err := tls.LoadX509KeyPair("certs/ssl.cert", "certs/ssl.key")
	if err != nil {
    	        log.Fatal(err)
	}
	config := &tls.Config{Certificates: []tls.Certificate{cer}}

	// Start server with https/ssl enabled
	app.Listen(443, config)
}

This was referenced Mar 4, 2020
@Fenny Fenny added the solved label Mar 4, 2020
@Fenny Fenny closed this as completed Mar 4, 2020
@regnaio
Copy link

regnaio commented Dec 6, 2021

Hi @Terisback v1.8.2 will support custom TLS configs

package main

import (
    "crypto/tls"
    "github.com/gofiber/fiber"
)

func main() {
	app := fiber.New()

	app.Get("/", func(c *fiber.Ctx) {
		c.Send(c.Protocol()) // => https
	})

	cer, err := tls.LoadX509KeyPair("certs/ssl.cert", "certs/ssl.key")
	if err != nil {
    	        log.Fatal(err)
	}
	config := &tls.Config{Certificates: []tls.Certificate{cer}}

	// Start server with https/ssl enabled
	app.Listen(443, config)
}

Can I please ask if this is still a valid way to use a custom tls.Config in the current fiber v2.22.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants