summaryrefslogtreecommitdiff
path: root/config/initializers/0_license.rb
blob: 3db5ec0a91a96d22c274bda67140c8dcbe55c6e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

load_license = lambda do |dir:, license_name:|
  prefix = ENV['GITLAB_LICENSE_MODE'] == 'test' ? 'test_' : ''
  public_key_file = File.read(Rails.root.join(dir, ".#{prefix}license_encryption_key.pub"))
  public_key = OpenSSL::PKey::RSA.new(public_key_file)
  Gitlab::License.encryption_key = public_key
rescue
  warn "WARNING: No valid #{license_name} encryption key provided."
end

Gitlab.ee do
  load_license.call(dir: '.', license_name: 'license')
end

Gitlab.jh do
  load_license.call(dir: 'jh', license_name: 'JH license')
end