1
我正在使用google/api_client
library in ruby。我的代碼在開發和本地測試中工作正常,但在Travis-CI上不太好。我將我的私鑰作爲多行字符串存儲在本地和Travis上。我的代碼失敗在這裏:OpenSSL :: PKey :: RSAError:沒有PUB密鑰也沒有PRIV密鑰:沒有足夠的數據Travis-ci
require "google/api_client"
class GoogleCalendarAdapter
def key
OpenSSL::PKey::RSA.new(ENV["GOOGLE_P12_PEM"], "notasecret") # line 27
end
end
我已經通過了特拉維斯-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)>'
歡迎任何有關如何解決此問題的建議。