This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from Alfresco/develop
Certs fix
- Loading branch information
Showing
14 changed files
with
283 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
remote_file "#{Chef::Config[:file_cache_path]}/rds-combined-ca-bundle.pem" do | ||
source 'http://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem' | ||
pem_file = 'rds-combined-ca-bundle.pem' | ||
|
||
remote_file "#{Chef::Config[:file_cache_path]}/#{pem_file}" do | ||
source "http://s3.amazonaws.com/rds-downloads/#{pem_file}" | ||
owner 'root' | ||
group 'root' | ||
mode '0755' | ||
action :create_if_missing | ||
end | ||
|
||
execute 'split_certs' do | ||
command <<-EOF | ||
cd #{Chef::Config[:file_cache_path]} | ||
csplit -sz rds-combined-ca-bundle.pem '/-BEGIN CERTIFICATE-/' '{*}' | ||
EOF | ||
only_if { ::File.exist?("#{Chef::Config[:file_cache_path]}/rds-combined-ca-bundle.pem") } | ||
end | ||
|
||
truststore = node['alfresco']['truststore_file'] | ||
truststore_pass = node['alfresco']['truststore_password'] | ||
truststore_type = node['alfresco']['truststore_type'] | ||
|
||
certstore = node['alfresco']['certstore']['path'] | ||
certstore_pass = node['alfresco']['certstore']['pass'] | ||
|
||
ruby_block 'Import AWS RDS Certs' do | ||
block do | ||
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) | ||
csplit = "cd #{Chef::Config[:file_cache_path]} && csplit -sz #{pem_file} '/-BEGIN CERTIFICATE-/' '{*}'" | ||
shell_out(csplit) | ||
Dir.glob("#{Chef::Config[:file_cache_path]}/xx*").each do |cert| | ||
Mixlib::ShellOut.new( | ||
%[ keytool -import -keystore #{truststore} -storepass #{truststore_pass} -storetype #{truststore_type} -noprompt \ | ||
-alias \"$(openssl x509 -noout -text -in #{cert} | perl -ne 'next unless /Subject:/; s/.*CN=//; print')\" -file #{cert} ] | ||
).run_command | ||
alias_cmd = "openssl x509 -noout -text -in #{cert} | perl -ne 'next unless /Subject:/; s/.*CN=//; print'" | ||
crt_alias = shell_out(alias_cmd).stdout.chomp.split.join | ||
f = Chef::Resource::JavaCertificate.new('java_certificate', run_context) | ||
f.cert_alias = crt_alias | ||
f.cert_file = cert | ||
f.keystore_path = certstore | ||
f.keystore_passwd = certstore_pass | ||
f.run_action :install | ||
# Java certificate library don't have option of storetype other than JKS hence passing this way | ||
tstore_cmd = "keytool -import -keystore #{truststore} -storepass #{truststore_pass} -storetype #{truststore_type} -noprompt -alias #{crt_alias} -file #{cert}" | ||
shell_out(tstore_cmd) | ||
end | ||
end | ||
action :run | ||
end | ||
|
||
ssl_db_conf = " -Djavax.net.ssl.keyStore=#{certstore} -Djavax.net.ssl.keyStorePassword=#{certstore_pass}" | ||
node.default['alfresco']['repo_tomcat_instance']['java_options']['others'] = "#{node['alfresco']['repo_tomcat_instance']['java_options']['others']} #{ssl_db_conf}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'json' | ||
|
||
ssl_folder = '/etc/pki/tls/certs' | ||
filename = 'alfresco' | ||
|
||
file = File.read('test/integration/data_bags/ssl/certs.json') | ||
ssl_databag_test = JSON.parse(file) | ||
|
||
control 'alfresco-10' do | ||
impact 0.5 | ||
title 'Certs files creation and value check' | ||
|
||
describe file("#{ssl_folder}/#{filename}.key") do | ||
it { should exist } | ||
its('content') { should match ssl_databag_test['key'].to_s } | ||
end | ||
|
||
describe file("#{ssl_folder}/#{filename}.crt") do | ||
it { should exist } | ||
its('content') { should match ssl_databag_test['crt'].to_s } | ||
end | ||
|
||
describe file("#{ssl_folder}/#{filename}.chain") do | ||
it { should exist } | ||
its('content') { should match ssl_databag_test['chain'].to_s } | ||
end | ||
|
||
describe file("#{ssl_folder}/#{filename}.nginxcrt") do | ||
it { should exist } | ||
its('content') { should match ssl_databag_test['nginxcrt'].to_s } | ||
end | ||
|
||
describe file("#{ssl_folder}/#{filename}.dhparam") do | ||
it { should exist } | ||
its('content') { should match ssl_databag_test['dhparam'].to_s } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
control 'Java version' do | ||
impact 1.0 | ||
title 'Check for Oracle Java' | ||
desc 'Determine if Java flavor is OracleJDK and not OpenJDK' | ||
describe command("java -version 2>&1 >/dev/null | grep 'java' | awk '{print $1}'") do | ||
its(:stdout) { should match(/java/) } | ||
its(:stdout) { should_not match(/openjdk/) } | ||
end | ||
end |
Oops, something went wrong.