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")
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助