将InsecureSkipVerify与Appengine一起使用时出错

时间:2019-02-02 17:01:13

标签: google-app-engine go google-cloud-platform tls1.2

我正在尝试将InsecureSkipVerify: true参数与appengine一起使用,但是在执行dev_appserver.py app.yaml代码时出现以下错误:

  

错误2019-02-02 16:44:49,039 http_runtime.py:420]错误的运行时进程端口['']

     

紧急:接口转换:http.RoundTripper是init.failingTransport,而不是* http.Transport

appengine.Main()中已内置的端口

然后如何将InsecureSkipVerifyappengine一起使用?

app.yaml

runtime: go
api_version: go1

handlers:
- url: /.*
  script: _go_app

main.go

package main

import (
    "encoding/json"
    "github.com/gorilla/mux"
    "net/http"
    "google.golang.org/appengine"
    "crypto/tls"
)

type Foo struct {
    Text string `json:"text"`
}

func GetInfo(w http.ResponseWriter, r *http.Request) {
    json.NewEncoder(w).Encode(Foo{"hello"})
}

func init(){
    r := mux.NewRouter()
    r.HandleFunc("/sample", GetInfo)
    http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
    http.Handle("/", r)
}

func main() {
    appengine.Main()
}

0 个答案:

没有答案