Skip to content

Commit c912c99

Browse files
committed
Include JRE Certificates
Previously, the Trust Store Builder only added certificates from the container. This would break compatibility for anyone currently using the JRE's built in trust store to get certificates into the system. This change adds support for getting certificates out of the JRE's cacerts as well. [resolves cloudfoundry#372]
1 parent 6a93f2d commit c912c99

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

.idea/dictionaries/bhale.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/container_certificate_trust_store.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
# Container certificate truststore configuration
1717
---
18-
version: 1.+
18+
version: 2.+
1919
repository_root: "{default.repository.root}/container-certificate-trust-store"
2020
enabled: true

lib/java_buildpack/framework/container_certificate_trust_store.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def compile
3131
with_timing("Adding certificates to #{trust_store.relative_path_from(@droplet.root)}") do
3232
FileUtils.mkdir_p trust_store.parent
3333

34-
shell "#{java} -jar #{@droplet.sandbox + jar_name} #{ca_certificates} #{trust_store} #{password}"
34+
shell "#{java} -jar #{@droplet.sandbox + jar_name} --container-source #{ca_certificates} --destination " \
35+
"#{trust_store} --destination-password #{password} --jre-source #{cacerts} --jre-source-password " \
36+
'changeit'
3537
end
3638
end
3739

@@ -66,6 +68,10 @@ def ca_certificates
6668
end
6769
end
6870

71+
def cacerts
72+
@droplet.java_home.root + 'lib/security/cacerts'
73+
end
74+
6975
def java
7076
@droplet.java_home.root + 'bin/java'
7177
end

spec/java_buildpack/framework/container_certificate_trust_store_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@
4747
allow(component).to receive(:ca_certificates).and_return(ca_certificates)
4848
allow(component).to receive(:shell).with("#{java_home.root}/bin/java -jar " \
4949
"#{sandbox}/container_certificate_trust_store-0.0.0.jar " \
50-
"#{ca_certificates} #{sandbox}/truststore.jks " \
51-
'java-buildpack-trust-store-password')
50+
"--container-source #{ca_certificates} " \
51+
"--destination #{sandbox}/truststore.jks " \
52+
'--destination-password java-buildpack-trust-store-password ' \
53+
"--jre-source #{java_home.root}/lib/security/cacerts " \
54+
'--jre-source-password changeit')
5255

5356
component.compile
5457
end

0 commit comments

Comments
 (0)