File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ Vault.configure do |config|
5353 # Custom SSL PEM, also read as ENV["VAULT_SSL_CERT"]
5454 config.ssl_pem_file = " /path/on/disk.pem"
5555
56+ # As an alternative to a pem file, you can provide the raw PEM string, also read in the following order of preference:
57+ # ENV["VAULT_SSL_PEM_CONTENTS_BASE64"] then ENV["VAULT_SSL_PEM_CONTENTS"]
58+ config.ssl_pem_contents = " -----BEGIN ENCRYPTED..."
59+
5660 # Use SSL verification, also read as ENV["VAULT_SSL_VERIFY"]
5761 config.ssl_verify = false
5862
Original file line number Diff line number Diff line change 11require "pathname"
2+ require "base64"
23
34module Vault
45 module Defaults
@@ -126,7 +127,11 @@ def ssl_ciphers
126127 # the value for {#ssl_pem_file}, if set.
127128 # @return [String, nil]
128129 def ssl_pem_contents
129- ENV [ "VAULT_SSL_PEM_CONTENTS" ]
130+ if ENV [ "VAULT_SSL_PEM_CONTENTS_BASE64" ]
131+ Base64 . decode64 ( ENV [ "VAULT_SSL_PEM_CONTENTS_BASE64" ] )
132+ else
133+ ENV [ "VAULT_SSL_PEM_CONTENTS" ]
134+ end
130135 end
131136
132137 # The path to a pem on disk to use with custom SSL verification
Original file line number Diff line number Diff line change @@ -128,11 +128,24 @@ module Vault
128128 end
129129
130130 describe ".ssl_pem_contents" do
131- it "defaults to ENV['VAULT_SSL_PEM_CONTENTS']" do
131+ it "defaults to ENV['VAULT_SSL_PEM_CONTENTS_BASE64']" do
132+ with_stubbed_env ( "VAULT_SSL_PEM_CONTENTS_BASE64" => "YWJjZC0xMjM0\n " ) do
133+ expect ( Defaults . ssl_pem_contents ) . to eq ( "abcd-1234" )
134+ end
135+ end
136+
137+ it "falls back to ENV['VAULT_SSL_PEM_CONTENTS']" do
132138 with_stubbed_env ( "VAULT_SSL_PEM_CONTENTS" => "abcd-1234" ) do
133139 expect ( Defaults . ssl_pem_contents ) . to eq ( "abcd-1234" )
134140 end
135141 end
142+
143+ it "returns nil if neither ENV['VAULT_SSL_PEM_CONTENTS'] \
144+ nor ENV['VAULT_SSL_PEM_CONTENTS_BASE64'] are present" do
145+ with_stubbed_env ( "VAULT_SSL_PEM_CONTENTS" => nil , "VAULT_SSL_PEM_CONTENTS_BASE64" => nil ) do
146+ expect ( Defaults . ssl_pem_contents ) . to eq ( nil )
147+ end
148+ end
136149 end
137150
138151 describe ".ssl_pem_file" do
You can’t perform that action at this time.
0 commit comments