Go-Gin上使用SSL

自签

openssl req -newkey rsa:4096 -nodes -keyout server.key -out server.csr
openssl x509 -signkey server.key -in server.csr -req -days 365 -out server.crt

示例

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	router := gin.Default()
	router.GET("/", func(c *gin.Context) {
		c.JSON(200, "ok")
	})
	router.RunTLS(":443", "./server.crt", "./server.key")
}

参考《在Go-Gin上使用自簽SSL》

你可能感兴趣的:(Golang)