Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion spec/puppet-server-lib/puppet/jvm/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,23 @@
end
end

it "falls back to the vendored PEM CA bundle when the keystore is absent" do
stub_const('Puppet::Server::Config::PUPPET_KEYSTORE_LOCATION',
'spec/fixtures/does-not-exist')
stub_const('Puppet::Server::Config::PUPPET_CA_BUNDLE_LOCATION',
'spec/fixtures/ca-cert.pem')

expect(Puppet).not_to receive(:warning)

ssl_context = Puppet::Server::Config.puppet_and_system_ssl_context
expect(ssl_context).to be_a_kind_of(Java::JavaxNetSsl::SSLContext)
end

it "warns if :ssl_trust_store is set but not readable" do
Puppet[:ssl_trust_store] = "spec/fixtures/foo.pem"
allow(File).to receive(:exist?).and_return(false)

expect(Puppet).to receive(:warning).with(/Could not find OpenVox-vendored keystore/)
expect(Puppet).to receive(:warning).with(/Could not find an OpenVox-vendored trust store/)
expect(Puppet).to receive(:warning).with(/The 'ssl_trust_store' setting does not refer to a file/)

Puppet::Server::Config.puppet_and_system_ssl_context
Expand Down
11 changes: 10 additions & 1 deletion src/ruby/puppetserver-lib/puppet/server/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class Puppet::Server::Config
PUPPET_KEYSTORE_LOCATION = '/opt/puppetlabs/puppet/ssl/puppet-cacerts'
PUPPET_CA_BUNDLE_LOCATION = '/opt/puppetlabs/puppet/ssl/cert.pem'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think it's better to have a shared truststore for agent and server instead of two. Also handling Java keystores is annoying. But I am wondering if this could lead to any issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we stick to this, we can also remove PUPPET_KEYSTORE_LOCATION

CERT_REGEX = /.*-----BEGIN CERTIFICATE-----.*/

def self.initialize_puppet_server(puppet_server_config)
Expand Down Expand Up @@ -82,8 +83,16 @@ def self.load_puppet_and_system_ssl_context
truststore = stores['truststore']
if File.exist?(PUPPET_KEYSTORE_LOCATION)
associate_entries(truststore, PUPPET_KEYSTORE_LOCATION)
elsif File.exist?(PUPPET_CA_BUNDLE_LOCATION)
# puppet-runtime stopped shipping the Java keystore form of the
# vendored CA bundle (puppet-runtime@066fd48); load the PEM bundle
# it still ships instead.
SSLUtils.associateCertsFromReader(
truststore,
'openvox_vendored_ca_bundle',
FileReader.new(PUPPET_CA_BUNDLE_LOCATION))
else
Puppet.warning("Could not find OpenVox-vendored keystore at '#{PUPPET_KEYSTORE_LOCATION}'")
Puppet.warning("Could not find an OpenVox-vendored trust store at '#{PUPPET_KEYSTORE_LOCATION}' or '#{PUPPET_CA_BUNDLE_LOCATION}'")
end

if additional_store_location = Puppet[:ssl_trust_store]
Expand Down