package main import ( "github.com/gin-gonic/gin" "log" "net/http" ) // 测试go语言证书访问 // openssl genrsa -out server.key 2048 // openssl req -nodes -new -key server.key -subj "/CN=localhost" -out server.csr // openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt func main() { r := gin.Default() r.GET("/ssl", HandleSsl) r.run(addr ) { err := r.RunTLS(addr, "server.crt", "server.key") } err := r.RunTLS(":9000", "server.crt", "server.key") if err != nil { log.Fatal(err) } } func HandleSsl(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"msg": "hello"}) }
标签:err,server,ssl,key,go,gin,out From: https://www.cnblogs.com/cjyp/p/16710976.html