Class: JSSWebHooks::SelfSignedCert
- Inherits:
-
Object
- Object
- JSSWebHooks::SelfSignedCert
- Defined in:
- lib/jss/webhooks/server_app/self_signed_cert.rb
Overview
An on-the-fly generated, self-signed ssl certificate with matching private key.
Constant Summary collapse
- DFT_C =
"US"- DFT_ST =
"California"- DFT_L =
"Emeryville"- DFT_O =
"Pixar"- DFT_OU =
"MacTeam"- DFT_CN =
"localhost"
Instance Attribute Summary collapse
-
#certificate ⇒ Object
readonly
Returns the value of attribute certificate.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ SelfSignedCert
constructor
A new instance of SelfSignedCert.
Constructor Details
#initialize(args = {}) ⇒ SelfSignedCert
Returns a new instance of SelfSignedCert.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/jss/webhooks/server_app/self_signed_cert.rb', line 42 def initialize (args = {}) args[:c] ||= DFT_C args[:st] ||= DFT_ST args[:l] ||= DFT_L args[:o] ||= DFT_O args[:ou] ||= DFT_OU args[:cn] ||= DFT_CN name = "/C=#{args[:c]}/ST=#{args[:st]}/L=#{args[:l]}/O=#{args[:o]}/OU=#{args[:ou]}/CN=#{args[:cn]}" ca = OpenSSL::X509::Name.parse(name) key = OpenSSL::PKey::RSA.new(1024) crt = OpenSSL::X509::Certificate.new crt.version = 2 crt.serial = 1 crt.subject = ca crt.issuer = ca crt.public_key = key.public_key crt.not_before = Time.now crt.not_after = Time.now + 1 * 365 * 24 * 60 * 60 # 1 year @certificate = crt @private_key = key end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Returns the value of attribute certificate.
40 41 42 |
# File 'lib/jss/webhooks/server_app/self_signed_cert.rb', line 40 def certificate @certificate end |
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
40 41 42 |
# File 'lib/jss/webhooks/server_app/self_signed_cert.rb', line 40 def private_key @private_key end |