Skip to content

Commit d22816b

Browse files
minli1robhoes
authored andcommitted
CP-29196: Enable FIPS mode if existence of cc preparations (xapi-project#3722)
* CP-29196: Enable FIPS mode if existence of cc preparations * pool-cert-install use trust instead of rehas * Add uninstall * Add update ca bundle script * Rework comments 1. Add function 'update_ca_bundle'. 2. Define 'certificate_path' in xapi instead of Stunnel. 3. Refine 'CC_PREPARATIONS' checking to highlight 'x' dummy * Use temp file in 'update-ca-bundle.sh' to avoid potential incomplete file Signed-off-by: Min Li <[email protected]>
1 parent 4851cc6 commit d22816b

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

ocaml/xapi/certificates.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ let c_rehash = "/usr/bin/c_rehash"
2828
let pem_certificate_header = "-----BEGIN CERTIFICATE-----"
2929
let pem_certificate_footer = "-----END CERTIFICATE-----"
3030

31+
let certificate_path = "/etc/stunnel/certs"
32+
3133
let library_path is_cert =
32-
if is_cert then Stunnel.certificate_path else Stunnel.crl_path
34+
if is_cert then certificate_path else Stunnel.crl_path
3335

3436
let library_filename is_cert name =
3537
Filename.concat (library_path is_cert) name
@@ -45,6 +47,8 @@ let rehash () =
4547
rehash' (library_path true);
4648
rehash' (library_path false)
4749

50+
let update_ca_bundle () = ignore (execute_command_get_output "/opt/xensource/bin/update-ca-bundle.sh" [])
51+
4852
let get_type is_cert =
4953
if is_cert then "certificate" else "CRL"
5054

@@ -130,7 +134,7 @@ let host_install is_cert ~name ~cert =
130134
mkdir_cert_path is_cert;
131135
write_string_to_file filename cert;
132136
Unix.chmod filename (cert_perms is_cert);
133-
rehash()
137+
update_ca_bundle ()
134138
with
135139
| e ->
136140
warn "Exception installing %s %s: %s" (get_type is_cert) name
@@ -146,7 +150,7 @@ let host_uninstall is_cert ~name =
146150
debug "Uninstalling %s %s" (get_type is_cert) name;
147151
try
148152
Sys.remove filename;
149-
rehash()
153+
update_ca_bundle ()
150154
with
151155
| e ->
152156
warn "Exception uninstalling %s %s: %s" (get_type is_cert) name

scripts/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ install:
6666
$(IPROG) generate_ssl_cert $(DESTDIR)$(LIBEXECDIR)
6767
$(IPROG) nbd-firewall-config.sh $(DESTDIR)$(LIBEXECDIR)
6868
$(IPROG) fix_firewall.sh $(DESTDIR)$(BINDIR)
69+
$(IPROG) update-ca-bundle.sh $(DESTDIR)$(BINDIR)
6970
mkdir -p $(DESTDIR)$(OPTDIR)/debug
7071
$(IPROG) debug_ha_query_liveset $(DESTDIR)$(OPTDIR)/debug
7172
$(IPROG) xe-scsi-dev-map $(DESTDIR)$(BINDIR)

scripts/init.d-xapissl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ writeconffile () {
9090
echo "; Autogenerated by ${0}" > $SSLCONFFILE
9191
writec '; during xapi start-up.'
9292
writec '; '
93-
if [ ${ANCIENT_STUNNEL} = 0 ]; then
93+
if [ ${ANCIENT_STUNNEL} = 0 ] && [ x"$CC_PREPARATIONS" != x"true" ]; then
9494
# stunnel 4.56 fips demands sslVersion = TLSv1 (not "all" or even
9595
# "TLSv1.2") so we cannot use fips mode.
9696
writec 'fips = no'

scripts/update-ca-bundle.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) Citrix Systems 2008. All rights reserved.
4+
#
5+
6+
set -e
7+
8+
mkdir -p /etc/stunnel
9+
find /etc/stunnel/certs -name '*.pem' | xargs cat > /etc/stunnel/xapi-stunnel-ca-bundle.pem.tmp
10+
mv /etc/stunnel/xapi-stunnel-ca-bundle.pem.tmp /etc/stunnel/xapi-stunnel-ca-bundle.pem

0 commit comments

Comments
 (0)