"ruby sign a certificate with the CA" Code Answer's
You're definitely familiar with the best coding language Ruby that developers use to develop their projects and they get all their queries like "ruby sign a certificate with the CA" answered properly. Developers are finding an appropriate answer about ruby sign a certificate with the CA related to the Ruby coding language. By visiting this online portal developers get answers concerning Ruby codes question like ruby sign a certificate with the CA. Enter your desired code related query in the search bar and get every piece of information about Ruby code related question on ruby sign a certificate with the CA.
ruby sign a certificate with the CA
root_key = OpenSSL::PKey::RSA.new 2048 # the CA's public/private key
root_ca = OpenSSL::X509::Certificate.new
root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate
root_ca.serial = 1
root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA"
root_ca.issuer = root_ca.subject # root CA's are "self-signed"
root_ca.public_key = root_key.public_key
root_ca.not_before = Time.now
root_ca.not_after = root_ca.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity
ef = OpenSSL::X509::ExtensionFactory.new
ef.subject_certificate = root_ca
ef.issuer_certificate = root_ca
root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true))
root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true))
root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
root_ca.sign(root_key, OpenSSL::Digest::SHA256.new)
Source: ruby-doc.org
ruby sign a certificate with the CA
key = OpenSSL::PKey::RSA.new 2048
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.serial = 2
cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate"
cert.issuer = root_ca.subject # root CA is the issuer
cert.public_key = key.public_key
cert.not_before = Time.now
cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60 # 1 years validity
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)
Source: ruby-doc.org
All those coders who are working on the Ruby based application and are stuck on ruby sign a certificate with the CA can get a collection of related answers to their query. Programmers need to enter their query on ruby sign a certificate with the CA related to Ruby code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about ruby sign a certificate with the CA for the programmers working on Ruby code while coding their module. Coders are also allowed to rectify already present answers of ruby sign a certificate with the CA while working on the Ruby language code. Developers can add up suggestions if they deem fit any other answer relating to "ruby sign a certificate with the CA". Visit this developer's friendly online web community, CodeProZone, and get your queries like ruby sign a certificate with the CA resolved professionally and stay updated to the latest Ruby updates.