Ruby OpenSSL::PKey::RSA错误:既不是PUB密钥也不是PRIV密钥:travis ci上的数据不足

Ruby OpenSSL::PKey::RSA错误:既不是PUB密钥也不是PRIV密钥:travis ci上的数据不足,ruby,travis-ci,Ruby,Travis Ci,我正在利用这个机会。我的代码在开发和本地测试中运行良好,但在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网络控制

我正在利用这个机会。我的代码在开发和本地测试中运行良好,但在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网络控制台将GOOGLE_P12_PEM环境变量定义为:

“----开始RSA私钥------\nMIICXQIBAAK…\n。。。
\n-----结束RSA私钥------\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)>'
失败/错误:事件=日历。获取事件(开始时间、结束时间)
OpenSSL::PKey::RSA错误:
PUB密钥和PRIV密钥都不可用:数据不足
#./lib/google\u calendar\u adapter.rb:27:in'initialize'
#./lib/google\u calendar\u adapter.rb:27:in'new'
#./lib/google\u calendar\u adapter.rb:27:in'key'
#./lib/google\u calendar\u adapter.rb:36:in`oauth2\u client'
#./lib/google\u calendar\u adapter.rb:49:in'google\u api\u client'
#./lib/google\u calendar\u adapter.rb:15:in'fetch\u events'
#./spec/lib/google\u calendar\u adapter\u spec.rb:18:in'block(3层)in'

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

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