Skip to content

Commit f321fba

Browse files
committed
🔨 Improve config for cert_chain
1 parent 630b43d commit f321fba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

version_gem.gemspec

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ Gem::Specification.new do |spec|
1313
# Ref: https://gitlab.com/oauth-xx/version_gem/-/issues/3
1414
# Hence, only enable signing if the cert_file is present.
1515
# See CONTRIBUTING.md
16-
cert_file = ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")
17-
if cert_file && File.exist?(File.join(__dir__, cert_file))
18-
spec.cert_chain = [ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")]
16+
default_user_cert = "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem"
17+
default_user_cert_path = File.join(__dir__, default_user_cert)
18+
cert_file_path = ENV.fetch("GEM_CERT_PATH", default_user_cert_path)
19+
cert_chain = cert_file_path.split(",")
20+
if cert_file_path && cert_chain.map { |fp| File.exist?(fp) }
21+
spec.cert_chain = cert_chain
1922
if $PROGRAM_NAME.end_with?("gem", "rake") && ARGV[0] == "build"
2023
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
2124
end

0 commit comments

Comments
 (0)