Skip to content

Instantly share code, notes, and snippets.

@jtdowney
Created December 24, 2010 15:57
Show Gist options
  • Save jtdowney/754361 to your computer and use it in GitHub Desktop.
Save jtdowney/754361 to your computer and use it in GitHub Desktop.
require 'openssl'
key = OpenSSL::PKey::DSA.generate 1024
puts key.to_pem
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.serial = 1
cert.subject = OpenSSL::X509::Name.new [['CN', 'Test CA']]
cert.issuer = cert.subject
cert.not_before = Time.now
cert.not_after = Time.now + 365 * 24 * 60 * 60
cert.public_key = key.public_key
cert.sign key, OpenSSL::Digest::SHA1.new
puts cert.to_pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment