Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- key = OpenSSL::PKey::RSA.new(2048)
- cert = OpenSSL::X509::Certificate.new
- cert.version = 2
- cert.serial = 1
- cert.subject = x509_name
- cert.issuer = x509_name
- cert.public_key = key.public_key
- # Some time within the last 3 years
- cert.not_before = Time.now - rand(3600 * 24 * 365 * 3)
- # From http://developer.android.com/tools/publishing/app-signing.html
- # """
- # A validity period of more than 25 years is recommended.
- #
- # If you plan to publish your application(s) on Google Play, note
- # that a validity period ending after 22 October 2033 is a
- # requirement. You cannot upload an application if it is signed
- # with a key whose validity expires before that date.
- # """
- #
- # 32-bit Ruby (and 64-bit Ruby on Windows) cannot deal with
- # certificate not_after times later than Jan 1st 2038, since long is 32-bit.
- # Set not_after to a random time 2~ years before the first bad date.
- #
- # FIXME: this will break again randomly starting in late 2033, hopefully
- # all 32-bit systems will be dead by then...
- #
- # The timestamp 0x78045d81 equates to 2033-10-22 00:00:01 UTC
- cert.not_after = Time.at(0x78045d81 + rand(0x7fffffff - 0x78045d81))
- # If this line is left out, signature verification fails on OSX.
- cert.sign(key, OpenSSL::Digest::SHA1.new)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement