【问题标题】:OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key: not enough data on travis-ciOpenSSL::PKey::RSAError:PUB 密钥和 PRIV 密钥都没有:travis-ci 上的数据不足
【发布时间】:2015-02-25 09:04:29
【问题描述】:

我正在使用google/api_client library in ruby。我的代码在开发和本地测试中运行良好,但在 Travis-CI 上运行不佳。我将我的私钥存储为本地和 Travis 上的多行字符串。我的代码在这里失败:

require "google/api_client"

class GoogleCalendarAdapter
  def key
    OpenSSL::PKey::RSA.new(ENV["GOOGLE_P12_PEM"], "notasecret")  # line 27
  end
end

我已通过 Travis-CI Web 控制台将 GOOGLE_P12_PEM 环境变量定义为:

"-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAK...\n... \n-----END RSA PRIVATE KEY-----\n"

这是我收到的错误:

Failure/Error: events = calendar.fetch_events(start_time, end_time)
 OpenSSL::PKey::RSAError:
   Neither PUB key nor PRIV key: not enough data
 # ./lib/google_calendar_adapter.rb:27:in `initialize'
 # ./lib/google_calendar_adapter.rb:27:in `new'
 # ./lib/google_calendar_adapter.rb:27:in `key'
 # ./lib/google_calendar_adapter.rb:36:in `oauth2_client'
 # ./lib/google_calendar_adapter.rb:49:in `google_api_client'
 # ./lib/google_calendar_adapter.rb:15:in `fetch_events'
 # ./spec/lib/google_calendar_adapter_spec.rb:18:in `block (3 levels) in <top (required)>'

欢迎任何有关如何解决此问题的建议。

【问题讨论】:

    标签: ruby travis-ci


    【解决方案1】:

    我最终加密了我的 p12 文件,并提供了有关如何在我的 .travis.yml 中解密该文件的说明,如文档所述,here

    【讨论】:

      猜你喜欢
      • 2017-02-15
      • 2012-03-09
      • 2013-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-30
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多