Module: VagrantPlugins::CaCertificates::Cap::Redhat::UpdateCertificateBundle

Defined in:
lib/vagrant-ca-certificates/cap/redhat/update_certificate_bundle.rb

Overview

Capability for configuring the certificate bundle on Redhat.

Class Method Summary collapse

Class Method Details

.update_certificate_bundle(m) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-ca-certificates/cap/redhat/update_certificate_bundle.rb', line 9

def self.update_certificate_bundle(m)
  m.communicate.tap do |sh|
    if Redhat.legacy_certificate_bundle?(sh)
      sh.sudo(<<-SCRIPT)
BUNDLE=/etc/pki/tls/certs/ca-bundle.crt; 
PRIVATE=/etc/pki/tls/ca.private.crt; 
if ! [ "$(readlink $BUNDLE)" == "$PRIVATE" ]; then 
  find /etc/pki/tls/private -type f -exec cat {} \\; | cat $BUNDLE - > $PRIVATE ; 
fi
SCRIPT
      sh.sudo('/bin/ln -fsn /etc/pki/tls/ca.private.crt /etc/pki/tls/cert.pem')
      sh.sudo('/bin/ln -fsn /etc/pki/tls/ca.private.crt /etc/pki/tls/certs/ca-bundle.crt')
      sh.execute(<<-SCRIPT, shell: '/bin/bash', sudo: true)
if [ ! -z "$JAVA_HOME" ]; then \
find /etc/pki/tls/private -type f -exec $JAVA_HOME/bin/keytool -importcert \
 -trustcacerts -noprompt -storepass changeit \
 -keystore $JAVA_HOME/jre/lib/security/cacerts -file {} \\; \
else true; fi
      SCRIPT
    else
      sh.sudo('update-ca-trust enable')
      sh.sudo('update-ca-trust extract')
    end
  end
end