【发布时间】: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)>'
欢迎任何有关如何解决此问题的建议。
【问题讨论】: