Skip to content
Support Let's Encrypt for a Go server application.
Go
Branch: master
Clone or download
appleboy chore: upgrade gin to v1.5.0
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Latest commit ffaac87 Nov 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example feat(vendor): switch govendor to go module (#10) Jan 19, 2019
.editorconfig
.gitignore fix: update example. Apr 16, 2017
.travis.yml chore: support go1.13 (#16) Sep 4, 2019
LICENSE Initial commit Apr 16, 2017
README.md feat(vendor): switch govendor to go module (#10) Jan 19, 2019
autotls.go use tlsconfig with additional protos (#11) Apr 6, 2019
doc.go Update docs (#2) Aug 26, 2017
go.mod chore: upgrade gin to v1.5.0 Nov 29, 2019
go.sum chore: upgrade gin to v1.5.0 Nov 29, 2019

README.md

autotls

Build Status Go Report Card GoDoc Join the chat at https://gitter.im/gin-gonic/autotls

Support Let's Encrypt for a Go server application.

example

example for 1-line LetsEncrypt HTTPS servers.

package main

import (
	"log"

	"github.com/gin-gonic/autotls"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()

	// Ping handler
	r.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong")
	})

	log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
}

example for custom autocert manager.

package main

import (
	"log"

	"github.com/gin-gonic/autotls"
	"github.com/gin-gonic/gin"
	"golang.org/x/crypto/acme/autocert"
)

func main() {
	r := gin.Default()

	// Ping handler
	r.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong")
	})

	m := autocert.Manager{
		Prompt:     autocert.AcceptTOS,
		HostPolicy: autocert.HostWhitelist("example1.com", "example2.com"),
		Cache:      autocert.DirCache("/var/www/.cache"),
	}

	log.Fatal(autotls.RunWithManager(r, &m))
}
You can’t perform that action at this time.