duanbi8529 2017-08-17 12:06
浏览 202
已采纳

acme:<domain>的授权错误(acme / autocert)

When running the following code I get the error:

acme: authorization error for domain (where domain is replaced by my actual domain)

Has anyone else had this issue? The error returned does not give that much insight.

package main

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

    "golang.org/x/crypto/acme/autocert"
)

func main() {
    certManager := autocert.Manager{
        Prompt:     autocert.AcceptTOS,
        HostPolicy: autocert.HostWhitelist(<domain>), //your domain here
        Cache:      autocert.DirCache("cache"), //folder for storing certificates
    }

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello world"))
    })

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

    if err := server.ListenAndServeTLS("", ""); err != nil {
        print(err.Error())
    }
}
  • 写回答

1条回答 默认 最新

  • drcb19700 2017-08-17 13:06
    关注

    Perhaps your server is on port 8086 and the tls challenge is on port 443? Try instead serving on port 443 (You may have to setcap your binary to allow it to do this).

    See this issue on lets encrypt:

    https://github.com/letsencrypt/acme-spec/issues/33

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 Ubuntu20.04无法连接GitHub
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥30 C++行情软件的tick数据如何高效的合成K线