1,winserv服务器上,配置了域名
2,利用NSSM发布了go应用程序
3,走http,go服务,可以运行
4,走https,go服务,暂停状态,API无法访问
5,www.yiren13.com用的腾讯的SSL
6,本地调试
https://localhost:443/ascontent/all
有数据
7,部署服务
https://www.yiren13.com:443/ascontent/all
不能访问
google浏览器提示www.yiren13.com不能访问
8,router.RunTLS(":443", "./key/1_www.yiren13.com_bundle.crt", "./key/2_www.yiren13.com.key")
相关key的试了很多种方式,最终都是本地服务可以获取数据,部署到远程https都不能访问,没有数据
openssl pkcs12 -in E:\KEY\KR\www.yiren13.com.pfx -nodes -out server.pem
openssl rsa -in server.pem -out server.key
openssl x509 -in server.pem -out server.crt
9,请教大神,go 在winserv上,怎么跑https???
--------------------------------------
https改造代码块
---------------------------------------
package main
import (
"gin-demo/router"
"github.com/gin-gonic/gin"
"github.com/unrolled/secure"
)
func main() {
router := router.InitRouter()
router.Use(TlsHandler())
router.RunTLS(":443", "./key/1_www.yiren13.com_bundle.crt", "./key/2_www.yiren13.com.key")
}
func TlsHandler() gin.HandlerFunc {
return func(c *gin.Context) {
secureMiddleware := secure.New(secure.Options{
SSLRedirect: true,
SSLHost: "yiren13.com:443",
})
err := secureMiddleware.Process(c.Writer, c.Request)
// If there was an error, do not continue.
if err != nil {
return
}
c.Next()
}
}
有疑问加站长微信联系(非本文作者)