先生成ssl证书

openssl genrsa -out key.pem 2048
openssl req -new -x509 -key key.pem -out cert.pem -days 1095

 

然后,大概这样

package main

import (

    "log"
    "net/http"
)

func SayHello(w http.ResponseWriter, req *http.Request) {
    w.Write([]byte("Hello"))
}

func main() {

    http.HandleFunc("/", SayHello)
    err := http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err)
    }
}

 

附一个免费的ssl证书制造地方

http://zyan.cc/startssl/

 

相关文章:

  • 2022-03-01
  • 2022-01-11
  • 2021-06-28
  • 2021-12-25
  • 2021-12-06
  • 2022-12-23
  • 2021-07-20
  • 2021-09-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-12-09
  • 2022-01-22
  • 2022-12-23
相关资源
相似解决方案