我一直在使用golang.org/x/crypto/acme/autocert,它是由Go的核心开发人员开发的。 现在已经有几个月了,它运行一切正常。 : only %s host is allowed", allowedHost)}httpsSrv = makeHTTPServer()m := autocert.Manager{Prompt: autocert.AcceptTOS ,HostPolicy: hostPolicy,Cache: autocert.DirCache(dataDir),}httpsSrv.Addr = ":443"httpsSrv.TLSConfig = 在我们的例子中,我们将证书缓存到磁盘上,使用的是autocert.DirCache命令。 缓存只是一个界面,所以你可以在一个SQL数据库或Redis中执行你所存储的。 Autocert的文档很好地解释了这一点。 我们的例子假设的是最常见的情况:一个服务器仅响应一个域。你可以很容易地改变这一点。
示例展开代码语言:GoAI代码解释packagemainimport("crypto/tls""github.com/gofiber/fiber/v3""golang.org/x/crypto/acme/autocert app.Listen(":443",fiber.ListenConfig{TLSMinVersion:tls.VersionTLS12,})//自动证书管理(Let'sEncrypt)certManager:=&autocert.Manager {Prompt:autocert.AcceptTOS,HostPolicy:autocert.HostWhitelist("example.com"),Cache:autocert.DirCache("
usage: pwndrop [start|stop|install|remove|status] [-config <config_path>] [-debug] [-no-autocert] [-no-dns 'pwndrop.ini' in same directory as the executable)-debug : enable debug output-no-autocert : disable
#2981 Fix the model can not be registered correctly on Ubuntu 32bit #2997 Feature/yaml #3181 Feature/autocert
import ( "log" "github.com/gin-gonic/autotls" "github.com/gin-gonic/gin" "golang.org/x/crypto/acme/autocert 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))
Server: new(http.Server), // 创建一个https的 Server指针 TLSServer: new(http.Server), AutoTLSManager: autocert.Manager { Prompt: autocert.AcceptTOS, }, // 日志实例 Logger: log.New("echo"), // 控制台、日志可以彩色输出的实例 colorer
/proxy -autocert # Automatically request LetsEncrypt certificates 工具使用 首先,我们需要在目标设备上启动代理(无需特殊权限): $ .
Autocert : 一个 Kubernetes 附加组件,可自动向容器中注入 TLS/HTTPS 证书,加密容器之间的通信流量。
key.pem file [$SSL_KEY] --ssl.acme-location= dir where certificates will be stored by autocert
当然,我们还需要证书,这里我们可以使用golang.org/x/crypto/acme/autocert和Letss Encrypt,同时别忘了将http请求重定向到https,如果你的客户端是浏览器,
crypto/acme github.com/astaxie/beego/context github.com/astaxie/beego/vendor/golang.org/x/crypto/acme/autocert crypto/acme github.com/astaxie/beego/context github.com/astaxie/beego/vendor/golang.org/x/crypto/acme/autocert
color latest go: finding github.com/labstack/gommon/log latest go: finding golang.org/x/crypto/acme/autocert
通过Let’s Encrypt很容易申请, 可以使用golang.org/x/crypto/acme/autocert的GetCertificate函数。
color latest go: finding github.com/labstack/gommon/log latest go: finding golang.org/x/crypto/acme/autocert
new(http.Server), // 创建一个https的 Server指针 TLSServer: new(http.Server), AutoTLSManager: autocert.Manager { Prompt: autocert.AcceptTOS, }, // 日志实例 Logger: log.New("echo"), // 控制台、日志可以彩色输出的实例
10081:10081/tcp \ -p 10081:10081/udp \ # 第 7 行激活 Kuboard 中的 Lets Encrypt 客户端; -e KUBOARD_TLS_AUTOCERT
DRONE_GITEA_CLIENT_SECRET=xxxxxx - DRONE_GITEA_SERVER=http://localhost:3000/ - DRONE_TLS_AUTOCERT
DRONE_RUNNER_CAPACITY=3 \ --env=DRONE_SERVER_HOST=10.0.10.68 \ --env=DRONE_SERVER_PROTO=http \ --env=DRONE_TLS_AUTOCERT