Class: Certificate
- Inherits:
-
Object
- Object
- Certificate
- Extended by:
- Forwardable
- Defined in:
- lib/letsencrypt/cli/support/certificate.rb
Instance Attribute Summary collapse
-
#x509 ⇒ Object
readonly
Returns the value of attribute x509.
-
#x509_chain ⇒ Object
readonly
Returns the value of attribute x509_chain.
Instance Method Summary collapse
- #chain_to_pem ⇒ Object
- #common_name ⇒ Object
- #fullchain_to_pem ⇒ Object
-
#initialize(fullchain_certificate) ⇒ Certificate
constructor
A new instance of Certificate.
- #x509_fullchain ⇒ Object
Constructor Details
#initialize(fullchain_certificate) ⇒ Certificate
Returns a new instance of Certificate.
8 9 10 11 12 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 8 def initialize(fullchain_certificate) fullchain_array = fullchain_certificate.strip.split("\n\n") @x509 = OpenSSL::X509::Certificate.new(fullchain_array.first) @x509_chain = fullchain_array[1..-1].map { |cert| OpenSSL::X509::Certificate.new(cert) } end |
Instance Attribute Details
#x509 ⇒ Object (readonly)
Returns the value of attribute x509.
4 5 6 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 4 def x509 @x509 end |
#x509_chain ⇒ Object (readonly)
Returns the value of attribute x509_chain.
4 5 6 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 4 def x509_chain @x509_chain end |
Instance Method Details
#chain_to_pem ⇒ Object
14 15 16 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 14 def chain_to_pem x509_chain.map(&:to_pem).join("\n") end |
#common_name ⇒ Object
26 27 28 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 26 def common_name x509.subject.to_a.find { |name, _, _| name == 'CN' }[1] end |
#fullchain_to_pem ⇒ Object
22 23 24 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 22 def fullchain_to_pem x509_fullchain.map(&:to_pem).join("\n") end |
#x509_fullchain ⇒ Object
18 19 20 |
# File 'lib/letsencrypt/cli/support/certificate.rb', line 18 def x509_fullchain [x509, *x509_chain] end |