What causes urn:acme:error:unauthorized 403 error in golang's acme/autocert?

What causes urn:acme:error:unauthorized 403 error in golang's acme/autocert?

完整的错误信息是:

403 urn:acme:error:unauthorized: Account creation on ACMEv1 is disabled. Please upgrade your ACME client to a version that supports ACMEv2 / RFC 8555. See https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430 for details

我用谷歌搜索并查看了那个 link,但我只是在使用:

golang.org/x/crypto/acme/autocert

以非常正常的方式打包:

package main

import (
    "crypto/tls"
    "net/http"

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

func main() {

    router := gin.Default()
    hosts := []string{"yourdomain.com"}
    certManager := autocert.Manager{
        Prompt:     autocert.AcceptTOS,
        HostPolicy: autocert.HostWhitelist(hosts...),
        Cache:      autocert.DirCache("/certs"),
    }

    server := &http.Server{
        Addr:    ":https",
        Handler: router,
        TLSConfig: &tls.Config{
            GetCertificate: certManager.GetCertificate,
        },
    }

    server.ListenAndServeTLS("", "")
}

事实上,这段代码 运行 在过去的 6 个月里运行良好。但是就在今天,我切换了它所在的服务器,现在收到了上面的消息。

我尝试获取最新版本的 golang,但仍然是同样的问题。

我将主机的 DNS 更改为这个新服务器的 ip,服务器的主机名是正确的。

据我所知,它与以前的工作服务器 100% 相同,但使用了新的 IP。

golang 的 acme/autocert 真的已经过时了,不使用 ACMEv2 了吗?

这条语句:

In fact this code has been running and working fine for the last 6 months. But just today I switched the server it was on and now get the above message.

可能表明您正在针对 golang.org/x/crypto 的旧版本构建 - 检查您的 go.mod 文件并确保您使用的是相当新的版本。我最近完成了一个使用几乎相同代码的项目。我的 go.mod 中的 require 看起来像这样:

golang.org/x/crypto v0.0.0-20200602180216-279210d13fed