Issue #7980 has been reported by dimytch (Dimitri Peka).

----------------------------------------
Bug #7980: Segmentation fault when generating new key with OpenSSL
https://bugs.ruby-lang.org/issues/7980

Author: dimytch (Dimitri Peka)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]


The code below makes ruby to crash
If I change

(({
  cert.version, cert.serial = 2
}))

to
(({
  cert.version = 2
  cert.serial = 2
}))

it passes to the undefined variable ((|root_ca|)) as expected

(({
#!/usr/bin/ruby
# encoding: utf-8

require 'openssl'

def new_key
  key = OpenSSL::PKey::RSA.new 4096
  cert = OpenSSL::X509::Certificate.new 
  cert.version, cert.serial = 2
  cert.subject = OpenSSL::X509::Name.parse '/DC=Ivan Ivanov/DC=8055645654/DC=h@h/DC=/OU=client/O=Kontora/C=KZ'
  cert.issuer = root_ca.subject
  cert.public_key = key.public_key
  cert.not_before = Time.now
  cert.not_after = cert.not_before + 2 * 365 * 24 * 60 * 60
  ef = OpenSSL::X509::ExtensionFactory.new
  ef.subject_certificate = cert
  ef.issuer_certificate = root_ca
  cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true))
  cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
  cert.sign(@@root_key, OpenSSL::Digest::SHA256.new)
  return cert
end

puts new_key

}))


-- 
http://bugs.ruby-lang.org/