douhan4093 2017-07-21 08:49
浏览 4
已采纳

在Google App Engine中处理HTTPS请求

In GAE I just use a default domain name: https://*.appspot.com, so I don't need to generate self-signed certificates.

Google App Engine docs specify how app.yaml should be configured to serve SSL connections:

https://cloud.google.com/appengine/docs/standard/go/config/appref#handlers_secure

But to serve an HTTPS connection in Go I write the following code example where I need to specify the certificates' filenames:

import (
    "net/http"
)

func main() {
    go http.ListenAndServeTLS(Address, "cert.pem", "key.pem", nil)
}

I don't understand how in this case to serve SSL requests if I don't generate certificates myself.

  • 写回答

1条回答 默认 最新

  • douge3830 2017-07-21 09:14
    关注

    You don't need to call http.ListenAndServeTLS on App Engine. If you have your app.yaml set up correctly, traffic will be served over SSL for you. A minimal App Engine app might be something like this:

    package main
    
    import (
        "fmt"
        "net/http"
    )
    
    func init() {
        http.HandleFunc("/", handler)
    }
    
    func handler(w http.ResponseWriter, r *http.Request) {
        fmt.Fprint(w, "Hi")
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本