Class: Billy::Authority
- Inherits:
-
Object
- Object
- Billy::Authority
- Includes:
- CertificateHelpers
- Defined in:
- lib/billy/ssl/authority.rb
Overview
This class is dedicated to the generation of a brand new certificate authority which can be picked up by a browser to verify and secure any communication with puffing billy. This authority certificate will be generated once on runtime and will sign each request certificate. So we do not have to deal with outdated certificates or stuff like that.
The resulting certificate authority is at its bare minimum to keep things simple and snappy. We do not handle a certificate revoke list (CRL) nor any other special key handling, even if we enable these extensions. It’s just a mimic of the mighty mitmproxy certificate authority file.
Instance Attribute Summary collapse
-
#cert ⇒ Object
readonly
Returns the value of attribute cert.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#cert_file ⇒ Object
Write out the certifcate to file (PEM format) and give back the file path.
-
#initialize ⇒ Authority
constructor
The authority generation does not require any arguments from outside of this class definition.
-
#key_file ⇒ Object
Write out the private key to file (PEM format) and give back the file path.
Methods included from CertificateHelpers
#days_ago, #days_from_now, #serial, #write_file
Constructor Details
#initialize ⇒ Authority
32 33 34 35 |
# File 'lib/billy/ssl/authority.rb', line 32 def initialize @key = OpenSSL::PKey::RSA.new(2048) @cert = generate end |
Instance Attribute Details
#cert ⇒ Object (readonly)
Returns the value of attribute cert.
22 23 24 |
# File 'lib/billy/ssl/authority.rb', line 22 def cert @cert end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
22 23 24 |
# File 'lib/billy/ssl/authority.rb', line 22 def key @key end |
Instance Method Details
#cert_file ⇒ Object
Write out the certifcate to file (PEM format) and give back the file path.
45 46 47 |
# File 'lib/billy/ssl/authority.rb', line 45 def cert_file write_file('ca.crt', cert.to_pem) end |
#key_file ⇒ Object
Write out the private key to file (PEM format) and give back the file path.
39 40 41 |
# File 'lib/billy/ssl/authority.rb', line 39 def key_file write_file('ca.key', key.to_pem) end |