代码之家  ›  专栏  ›  技术社区  ›  Thomas

“bq”命令行工具抛出证书\u验证\u失败

  •  4
  • Thomas  · 技术社区  · 7 年前

    更新(2019-02-07):the issue gcloud components update


    在过去几个月的某个时候,我的 bq 工具停止工作。即使是一件简单的事情也表明了这个错误:

    $ bq show
    BigQuery error in show operation: Cannot contact server. Please try again.
    Traceback: Traceback (most recent call last):
    File "/opt/google-cloud-sdk/platform/bq/bigquery_client.py", line 685, in BuildApiClient
    response_metadata, discovery_document = http.request(discovery_url)
    File "/opt/google-cloud-sdk/platform/bq/third_party/oauth2client_4_0/transport.py", line 176, in new_request
    redirections, connection_type)
    File "/opt/google-cloud-sdk/platform/bq/third_party/oauth2client_4_0/transport.py", line 283, in request
    connection_type=connection_type)
    File "/opt/google-cloud-sdk/platform/bq/third_party/httplib2/__init__.py", line 1626, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
    File "/opt/google-cloud-sdk/platform/bq/third_party/httplib2/__init__.py", line 1368, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
    File "/opt/google-cloud-sdk/platform/bq/third_party/httplib2/__init__.py", line 1288, in _conn_request
    conn.connect()
    File "/opt/google-cloud-sdk/platform/bq/third_party/httplib2/__init__.py", line 1082, in connect
    raise SSLHandshakeError(e)
    SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)
    

    我试过以下方法:

    • sudo gcloud components update (版本221.0.0)。
    • sudo pacman -Syu (系统更新)以获取最新的SSL证书集。这是一个ArchLinux,所以它一直都是最前沿的。
    • sudo gcloud components reinstall .
    • 正在卸载 google-cloud-sdk /opt/google-cloud-sdk 完全从 AUR .
    • --httplib2_debuglevel=3 (未记录有效值,找到值 3 here ). 这不会产生任何额外的输出。
    • --ca_certificates_file=/etc/ca-certificates/extracted/tls-ca-bundle.pem , --ca_certificates_file=/etc/ca-certificates/extracted/ca-bundle.trust.crt --ca_certificates_file=/etc/ssl/certs/ca-certificates.crt www.googleapis.com
    • 在源代码中发现 /opt/google-cloud-sdk/platform/bq/third_party/httplib2/cacerts.txt 默认情况下使用的证书包。如果我用这个试试 curl --cacert ... ,它仍然有效。
    • 设置 GOOGLE_APPLICATION_CREDENTIALS bq公司
    • 添加 --disable_ssl_validation . 这“起作用”,但显然不安全。

    其他人看到了吗,或者有想法如何调试/解决?

    2 回复  |  直到 7 年前
        1
  •  1
  •   brinox    7 年前

    我在使用Arch Linux时也看到了完全相同的问题。

    当你发布 bq 但是,我很确定 /opt/google-cloud-sdk/platform/bq/third_party/httplib2/cacerts.txt 因为旗子 --ca_certificates_file=/etc/ssl/certs/ca-certificates.crt /etc/ca-certificates/extracted/tls-ca-bundle.pem .

    我试过用 curl openssl s_client

    https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest
    

    而且效果很好。

    pyopenssl 包的版本为 18.0.0

        2
  •  0
  •   F10    7 年前

    有一个 public issue tracker 和你的行为相似。我建议 starring it

    如果你支持一个公司代理,请发表评论 #8 有一个场景是公司代理替换证书,并且在注释中提供了解决方法 #16

    希望有帮助。

    推荐文章