Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with FIPS-enabled Jammy BOSH stemcells #178

Merged
merged 2 commits into from
Dec 22, 2023
Merged
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
15 changes: 4 additions & 11 deletions jobs/credhub/templates/init_key_stores.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,17 @@ cat > ${PRIVATE_KEY_FILE} <<EOL
<%= p('credhub.tls.private_key') %>
EOL

# legacy option is needed for openssl 3 + openjdk8 see https://github.com/pivotal/credhub-release/issues/65
if openssl version | grep -q 3.0; then
LEGACY="-legacy"
else
LEGACY=""
fi

# Use Fips 140-2 compatible encryption algorithm
# Use Fips-compatible option(s)
if [ -f "/proc/sys/crypto/fips_enabled" ]; then
FIPS_OPTS="-certpbe PBE-SHA1-3DES -keypbe PBE-SHA1-3DES"
echo "Using Fips 140-2 compatible encryption algorithm PBE-SHA1-3DES to package cert and key with pkcs12"
FIPS_OPTS="-nomac"
echo "Using Fips-compatible option(s) to package cert and key with pkcs12"
else
FIPS_OPTS=""
fi


if [ -s ${CERT_FILE} ]; then
RANDFILE=/etc/sv/monit/.rnd openssl pkcs12 ${LEGACY} -export -in ${CERT_FILE} ${FIPS_OPTS} -inkey ${PRIVATE_KEY_FILE} -out cert.p12 -name ${CERT_ALIAS} \
RANDFILE=/etc/sv/monit/.rnd openssl pkcs12 -export -in ${CERT_FILE} ${FIPS_OPTS} -inkey ${PRIVATE_KEY_FILE} -out cert.p12 -name ${CERT_ALIAS} \
-password pass:k0*l*s3cur1tyr0ck$

${JAVA_HOME}/bin/keytool -importkeystore \
Expand Down
2 changes: 1 addition & 1 deletion spec/credhub/init_key_stores_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

it 'loads the TLS certificate' do
script = template.render(manifest)
expect(script).to include('openssl pkcs12 ${LEGACY} -export -in')
expect(script).to include('openssl pkcs12 -export -in')
end

context 'when trusted CAs are provided' do
Expand Down