2015-02-10 40 views
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)>' 

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

回答

1

我最终加密了我的p12文件,并提供了如何解密我的.travis.yml中的文件的说明,如记录,here

相关问题