Skip to content

Instantly share code, notes, and snippets.

@grempe
Created October 13, 2016 01:22
Show Gist options
  • Save grempe/f2a9822578d46c0545b614ced20d5695 to your computer and use it in GitHub Desktop.
Save grempe/f2a9822578d46c0545b614ced20d5695 to your computer and use it in GitHub Desktop.
A script to generate a Ruby gem signing certificate of N years length. Temporary workaround until this is built into Rubygems.
#!/usr/bin/env ruby
# Usage:
# ./gen_long_expire_gem_cert.rb [email protected] [years]
# See also:
# https://github.com/rubygems/rubygems/pull/1725
# https://github.com/djberg96/sys-uname/issues/5
require 'rubygems'
require 'rubygems/security'
require 'rubygems/commands/cert_command'
# change the constant to equal 10 years
years = ARGV[1].nil? ? 10 : ARGV[1].to_i
Gem::Security::ONE_YEAR = 31536000 * years
puts "Building a #{years} year cert..."
c = Gem::Commands::CertCommand.new
c.build ARGV[0].to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment