douwei1950 2017-04-03 04:46 采纳率: 0%
浏览 63
已采纳

SSL:GAE / Go上的CERTIFICATE_VERIFY_FAILED

I am developing GAE/Go application and trying to connect Google Big Query from local development server.

My code is like this.

import (
  "cloud.google.com/go/bigquery"
  "golang.org/x/net/context"
  "google.golang.org/api/option"
  gaeLog "google.golang.org/appengine/log"
  newappengine "google.golang.org/appengine"
)

func MyFunc(c *gin.Context) {
  r := c.Request
  ctx := newappengine.NewContext(r)
  client, err := bigquery.NewClient(ctx, PROJECT_ID, option.WithServiceAccountFile(SERVICE_ACCOUNT_JSON_FILE_PATH))
  if err != nil {
      (Error Handling)
  }

  tableList := client.Dataset(DATASET_ID).Tables(ctx)
  for {
    v, err := tableList.Next()
    if err == iterator.Done {
        break
    } else if err != nil {
        gaeLog.Errorf(ctx, "Failed to get meta-info: %v", err)
        return
    }
    :
  }
}

I invoked local development server with goapp.bat serve command. When I posted a request, I got an error.

api_dev.go:344: ERROR: Failed to get meta-info: Get https://www.googleapis.com/bigquery/v2/projects/myproject/datasets/mydataset/tables?alt=json&pageToken=: oauth2: cannot fetch token: Post https://accounts.google.com/o/oauth2/token: API error 6 (urlfetch: SSL_CERTIFICATE_ERROR): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)

I googled "CERTIFICATE_VERIFY_FAILED", but all I can find is python program. My application is GAE/Go program.

How can I avoid this error?

  • 写回答

1条回答 默认 最新

  • 普通网友 2017-04-08 14:47
    关注

    This is because Google has updated their server certificates but have not notified the Go SDK team of this, which still has the old certs.

    The solution seems fairly simple.

    1. Go to google_appengine\lib\cacerts\
    2. Rename cacerts.txt to cacerts.txt.old, and urlfetch_cacerts.txt to urlfetch_cacerts.txt.old
    3. Download the Python Linux SDK 1.9.52.
    4. In this Python SDK there's also google_appengine\lib\cacerts\ directory with those two cert files. Copy them over to your Go SDK.
    5. Rejoice! You now have newer certs.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计