Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
1021119 - make sure private keys are never world readable
Browse files Browse the repository at this point in the history
This should prevent similar mistakes in future.
  • Loading branch information
iNecas committed Oct 22, 2013
1 parent c414d26 commit 15e0108
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions modules/apache/manifests/certs.pp
Expand Up @@ -34,6 +34,11 @@
privkey { $apache_ssl_key:
ensure => present,
cert => Cert["${::certs::node_fqdn}-ssl"]
} ->
file { $apache_ssl_key:
owner => $apache::params::user,
group => $apache::params::group,
mode => '0400';
}

file { "${apache::params::configdir}/ssl.conf":
Expand Down
6 changes: 5 additions & 1 deletion modules/certs/lib/puppet/provider/katello_ssl_tool.rb
Expand Up @@ -175,7 +175,7 @@ def exists?
end

def create
File.open(resource[:path], "w") { |f| f << expected_content }
File.open(resource[:path], "w", mode) { |f| f << expected_content }
end

protected
Expand All @@ -198,6 +198,10 @@ def source_path
raise NotImplementedError
end

def mode
0644
end

def cert_details
return @cert_details if defined? @cert_details
if cert_resource = @resource[:cert]
Expand Down
4 changes: 4 additions & 0 deletions modules/certs/lib/puppet/provider/privkey/katello_ssl_tool.rb
Expand Up @@ -8,4 +8,8 @@ def source_path
cert_details[:privkey]
end

def mode
0400
end

end
2 changes: 1 addition & 1 deletion modules/kafo/manifests/foreman_certs.pp
Expand Up @@ -36,7 +36,7 @@

file { $client_key:
owner => "foreman",
mode => "400"
mode => "0400"
}

pubkey { $client_ca:
Expand Down
2 changes: 1 addition & 1 deletion modules/kafo/manifests/foreman_proxy_certs.pp
Expand Up @@ -36,7 +36,7 @@

file { $proxy_key:
owner => "foreman-proxy",
mode => "400"
mode => "0400"
}

pubkey { $proxy_ca:
Expand Down
2 changes: 1 addition & 1 deletion modules/kafo/manifests/puppet_certs.pp
Expand Up @@ -36,7 +36,7 @@

file { $client_key:
owner => "puppet",
mode => "400"
mode => "0400"
}

pubkey { $client_ca:
Expand Down

0 comments on commit 15e0108

Please sign in to comment.