Class: ApartmentAcmeClient::CertificateStorage::S3
- Inherits:
-
Object
- Object
- ApartmentAcmeClient::CertificateStorage::S3
- Defined in:
- lib/apartment_acme_client/certificate_storage/s3.rb
Constant Summary collapse
- ENCRYPTION_S3_NAME =
'server_encryption_client_private_key.der'
- CSR_ENCRYPTION_S3_NAME =
'csr_server_encryption_client_private_key.der'
Instance Method Summary collapse
-
#cert_exists? ⇒ Boolean
do we have a certificate on this server? We cannot start nginx when it is pointing at a non-existing certificate, so we need to check.
- #csr_private_key ⇒ Object
-
#initialize ⇒ S3
constructor
A new instance of S3.
- #private_key ⇒ Object
- #save_csr_private_key(private_key) ⇒ Object
-
#save_private_key(private_key) ⇒ Object
saves a private key to s3.
- #store_certificate_string(certificate_string) ⇒ Object
- #store_csr_private_key_string(csr_private_key_string) ⇒ Object
Constructor Details
#initialize ⇒ S3
Returns a new instance of S3.
8 9 10 11 12 13 14 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 8 def initialize @base_prefix = if ApartmentAcmeClient.lets_encrypt_test_server_enabled TEST_PREFIX else '' end end |
Instance Method Details
#cert_exists? ⇒ Boolean
do we have a certificate on this server? We cannot start nginx when it is pointing at a non-existing certificate, so we need to check
32 33 34 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 32 def cert_exists? File.exist?(cert_path('privkey.pem')) end |
#csr_private_key ⇒ Object
43 44 45 46 47 48 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 43 def csr_private_key s3_object = s3_file(csr_private_key_s3_filename) return nil unless s3_object.exists? s3_object.get.body.read end |
#private_key ⇒ Object
36 37 38 39 40 41 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 36 def private_key s3_object = s3_file(private_key_s3_filename) return nil unless s3_object.exists? s3_object.get.body.read end |
#save_csr_private_key(private_key) ⇒ Object
55 56 57 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 55 def save_csr_private_key(private_key) store_s3_file(csr_private_key_s3_filename, private_key.to_der) end |
#save_private_key(private_key) ⇒ Object
saves a private key to s3
51 52 53 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 51 def save_private_key(private_key) store_s3_file(private_key_s3_filename, private_key.to_der) end |
#store_certificate_string(certificate_string) ⇒ Object
19 20 21 22 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 19 def store_certificate_string(certificate_string) File.write(cert_path('cert.pem'), certificate_string) store_s3_file(derived_filename('cert.pem'), certificate_string) end |
#store_csr_private_key_string(csr_private_key_string) ⇒ Object
24 25 26 27 |
# File 'lib/apartment_acme_client/certificate_storage/s3.rb', line 24 def store_csr_private_key_string(csr_private_key_string) File.write(cert_path('privkey.pem'), csr_private_key_string) store_s3_file(derived_filename('privkey.pem'), csr_private_key_string) end |