Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis tls #334

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lib/travis/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,28 @@ def logger=(logger)
end

def redis_pool
@redis_pool ||= ConnectionPool.new { Redis.new( url: Travis.config.redis.url ) }
@redis_pool ||= ConnectionPool.new {
Redis.new(
url: Travis.config.redis.url,
ssl: Travis.config.redis.ssl || false,
ssl_params: redis_ssl_params
)
}
end

def redis_ssl_params
@redis_ssl_params ||=
begin
return nil unless Travis.config.redis.ssl

value = {}
value[:ca_path] = ENV['REDIS_SSL_CA_PATH'] if ENV['REDIS_SSL_CA_PATH']
value[:cert] = OpenSSL::X509::Certificate.new(File.read(ENV['REDIS_SSL_CERT_FILE'])) if ENV['REDIS_SSL_CERT_FILE']
value[:key] = OpenSSL::PKEY::RSA.new(File.read(ENV['REDIS_SSL_KEY_FILE'])) if ENV['REDIS_SSL_KEY_FILE']
value[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if Travis.config.ssl_verify == false
value
end
end

end
end
25 changes: 23 additions & 2 deletions lib/travis/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@

$stdout.sync = true

def redis_ssl_params
@redis_ssl_params ||= begin
return nil unless Travis.config.redis.ssl

value = {}
value[:ca_path] = ENV['REDIS_SSL_CA_PATH'] if ENV['REDIS_SSL_CA_PATH']
value[:cert] = OpenSSL::X509::Certificate.new(File.read(ENV['REDIS_SSL_CERT_FILE'])) if ENV['REDIS_SSL_CERT_FILE']
value[:key] = OpenSSL::PKEY::RSA.new(File.read(ENV['REDIS_SSL_KEY_FILE'])) if ENV['REDIS_SSL_KEY_FILE']
value[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if Travis.config.ssl_verify == false
value
end
end


if Travis.config.sentry.dsn
Sentry.init do |config|
config.dsn = Travis.config.sentry.dsn
Expand All @@ -38,7 +52,9 @@ def call(worker, msg, queue)

Sidekiq.configure_server do |config|
config.redis = {
:url => Travis.config.redis.url
url: Travis.config.redis.url,
ssl: Travis.config.redis.ssl || false,
ssl_params: redis_ssl_params
}
config.server_middleware do |chain|
chain.add Travis::Tasks::Middleware::Metriks
Expand All @@ -53,7 +69,12 @@ def call(worker, msg, queue)
Sidekiq.configure_client do |c|
url = Travis.config.redis.url
config = Travis.config.sidekiq
c.redis = { url: url, size: config[:pool_size] }
c.redis = {
url: url,
size: config[:pool_size],
ssl: Travis.config.redis.ssl || false,
ssl_params: redis_ssl_params
}
end
Sidekiq.default_configuration[:max_retries] = Travis.config.sidekiq.retry

Expand Down
2 changes: 1 addition & 1 deletion lib/travis/tasks/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def http_basic_auth
define host: "travis-ci.org",
host_domain: 'travis-ci.com',
github: { url: 'https://github.com' },
redis: { url: "redis://localhost:6379" },
redis: { url: "redis://localhost:6379", ssl: ENV['REDIS_SSL'] || false },
sentry: { },
metrics: { reporter: 'librato' },
sidekiq: { pool_size: 3, retry: 4 },
Expand Down