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》

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章