Sha256: 8d571db2440917a5e293cf475062c8f1af74a207758f95a2506274b4d6dde669
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
require 'fileutils' require 'certificate_authority' FileUtils.mkdir_p(certs_dir) # # Certificate Authority # ca = CertificateAuthority::Certificate.new ca.subject.common_name = 'honestachmed.com' ca.serial_number.number = 1 ca.key_material.generate_key ca.signing_entity = true ca.sign! 'extensions' => {'keyUsage' => {'usage' => %w(critical keyCertSign)}} ca_cert_path = File.join(certs_dir, 'ca.crt') ca_key_path = File.join(certs_dir, 'ca.key') File.write ca_cert_path, ca.to_pem File.write ca_key_path, ca.key_material.private_key.to_pem # # Server Certificate # server_cert = CertificateAuthority::Certificate.new server_cert.subject.common_name = '127.0.0.1' server_cert.serial_number.number = 1 server_cert.key_material.generate_key server_cert.parent = ca server_cert.sign! server_cert_path = File.join(certs_dir, 'server.crt') server_key_path = File.join(certs_dir, 'server.key') File.write server_cert_path, server_cert.to_pem File.write server_key_path, server_cert.key_material.private_key.to_pem # # Client Certificate # client_cert = CertificateAuthority::Certificate.new client_cert.subject.common_name = '127.0.0.1' client_cert.serial_number.number = 1 client_cert.key_material.generate_key client_cert.parent = ca client_cert.sign! client_cert_path = File.join(certs_dir, 'client.crt') client_key_path = File.join(certs_dir, 'client.key') File.write client_cert_path, client_cert.to_pem File.write client_key_path, client_cert.key_material.private_key.to_pem
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
http-0.7.4 | spec/support/create_certs.rb |
http-0.7.3 | spec/support/create_certs.rb |