Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 1 | # lib/tls |
| 2 | # Functions to control the configuration and operation of the TLS proxy service |
| 3 | |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 4 | # !! source _before_ any services that use ``SERVICE_HOST`` |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 5 | # |
| 6 | # Dependencies: |
| 7 | # |
| 8 | # - ``functions`` file |
| 9 | # - ``DEST``, ``DATA_DIR`` must be defined |
| 10 | # - ``HOST_IP``, ``SERVICE_HOST`` |
| 11 | # - ``KEYSTONE_TOKEN_FORMAT`` must be defined |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 12 | |
| 13 | # Entry points: |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 14 | # |
| 15 | # - configure_CA |
| 16 | # - init_CA |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 17 | # - cleanup_CA |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 18 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 19 | # - configure_proxy |
| 20 | # - start_tls_proxy |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 21 | |
Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 22 | # - stop_tls_proxy |
| 23 | # - cleanup_CA |
| 24 | |
Stanislaw Pitucha | 2e0f054 | 2014-06-27 16:05:53 +0100 | [diff] [blame] | 25 | # - make_root_CA |
| 26 | # - make_int_CA |
| 27 | # - make_cert ca-dir cert-name "common-name" ["alt-name" ...] |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 28 | # - start_tls_proxy HOST_IP 5000 localhost 5000 |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 29 | # - ensure_certificates |
| 30 | # - is_ssl_enabled_service |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 31 | # - enable_mod_ssl |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 32 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 33 | # Defaults |
| 34 | # -------- |
| 35 | |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 36 | if is_service_enabled tls-proxy; then |
| 37 | # TODO(dtroyer): revisit this below after the search for HOST_IP has been done |
| 38 | TLS_IP=${TLS_IP:-$SERVICE_IP} |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 39 | fi |
| 40 | |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 41 | DEVSTACK_HOSTNAME=$(hostname -f) |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 42 | DEVSTACK_CERT_NAME=devstack-cert |
| 43 | DEVSTACK_CERT=$DATA_DIR/$DEVSTACK_CERT_NAME.pem |
| 44 | |
| 45 | # CA configuration |
| 46 | ROOT_CA_DIR=${ROOT_CA_DIR:-$DATA_DIR/CA/root-ca} |
| 47 | INT_CA_DIR=${INT_CA_DIR:-$DATA_DIR/CA/int-ca} |
| 48 | |
| 49 | ORG_NAME="OpenStack" |
| 50 | ORG_UNIT_NAME="DevStack" |
| 51 | |
| 52 | # Stud configuration |
| 53 | STUD_PROTO="--tls" |
| 54 | STUD_CIPHERS='TLSv1+HIGH:!DES:!aNULL:!eNULL:@STRENGTH' |
| 55 | |
| 56 | |
| 57 | # CA Functions |
| 58 | # ============ |
| 59 | |
| 60 | # There may be more than one, get specific |
| 61 | OPENSSL=${OPENSSL:-/usr/bin/openssl} |
| 62 | |
| 63 | # Do primary CA configuration |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 64 | function configure_CA { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 65 | # build common config file |
| 66 | |
| 67 | # Verify ``TLS_IP`` is good |
| 68 | if [[ -n "$HOST_IP" && "$HOST_IP" != "$TLS_IP" ]]; then |
| 69 | # auto-discover has changed the IP |
| 70 | TLS_IP=$HOST_IP |
| 71 | fi |
| 72 | } |
| 73 | |
| 74 | # Creates a new CA directory structure |
| 75 | # create_CA_base ca-dir |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 76 | function create_CA_base { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 77 | local ca_dir=$1 |
| 78 | |
| 79 | if [[ -d $ca_dir ]]; then |
| 80 | # Bail out it exists |
| 81 | return 0 |
| 82 | fi |
| 83 | |
Dean Troyer | b1e3d0f | 2014-07-25 14:57:54 -0500 | [diff] [blame] | 84 | local i |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 85 | for i in certs crl newcerts private; do |
| 86 | mkdir -p $ca_dir/$i |
| 87 | done |
| 88 | chmod 710 $ca_dir/private |
| 89 | echo "01" >$ca_dir/serial |
| 90 | cp /dev/null $ca_dir/index.txt |
| 91 | } |
| 92 | |
| 93 | |
| 94 | # Create a new CA configuration file |
| 95 | # create_CA_config ca-dir common-name |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 96 | function create_CA_config { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 97 | local ca_dir=$1 |
| 98 | local common_name=$2 |
| 99 | |
| 100 | echo " |
| 101 | [ ca ] |
| 102 | default_ca = CA_default |
| 103 | |
| 104 | [ CA_default ] |
| 105 | dir = $ca_dir |
| 106 | policy = policy_match |
| 107 | database = \$dir/index.txt |
| 108 | serial = \$dir/serial |
| 109 | certs = \$dir/certs |
| 110 | crl_dir = \$dir/crl |
| 111 | new_certs_dir = \$dir/newcerts |
| 112 | certificate = \$dir/cacert.pem |
| 113 | private_key = \$dir/private/cacert.key |
| 114 | RANDFILE = \$dir/private/.rand |
| 115 | default_md = default |
| 116 | |
| 117 | [ req ] |
| 118 | default_bits = 1024 |
| 119 | default_md = sha1 |
| 120 | |
| 121 | prompt = no |
| 122 | distinguished_name = ca_distinguished_name |
| 123 | |
| 124 | x509_extensions = ca_extensions |
| 125 | |
| 126 | [ ca_distinguished_name ] |
| 127 | organizationName = $ORG_NAME |
| 128 | organizationalUnitName = $ORG_UNIT_NAME Certificate Authority |
| 129 | commonName = $common_name |
| 130 | |
| 131 | [ policy_match ] |
| 132 | countryName = optional |
| 133 | stateOrProvinceName = optional |
| 134 | organizationName = match |
| 135 | organizationalUnitName = optional |
| 136 | commonName = supplied |
| 137 | |
| 138 | [ ca_extensions ] |
| 139 | basicConstraints = critical,CA:true |
| 140 | subjectKeyIdentifier = hash |
| 141 | authorityKeyIdentifier = keyid:always, issuer |
| 142 | keyUsage = cRLSign, keyCertSign |
| 143 | |
| 144 | " >$ca_dir/ca.conf |
| 145 | } |
| 146 | |
| 147 | # Create a new signing configuration file |
| 148 | # create_signing_config ca-dir |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 149 | function create_signing_config { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 150 | local ca_dir=$1 |
| 151 | |
| 152 | echo " |
| 153 | [ ca ] |
| 154 | default_ca = CA_default |
| 155 | |
| 156 | [ CA_default ] |
| 157 | dir = $ca_dir |
| 158 | policy = policy_match |
| 159 | database = \$dir/index.txt |
| 160 | serial = \$dir/serial |
| 161 | certs = \$dir/certs |
| 162 | crl_dir = \$dir/crl |
| 163 | new_certs_dir = \$dir/newcerts |
| 164 | certificate = \$dir/cacert.pem |
| 165 | private_key = \$dir/private/cacert.key |
| 166 | RANDFILE = \$dir/private/.rand |
| 167 | default_md = default |
| 168 | |
| 169 | [ req ] |
| 170 | default_bits = 1024 |
| 171 | default_md = sha1 |
| 172 | |
| 173 | prompt = no |
| 174 | distinguished_name = req_distinguished_name |
| 175 | |
| 176 | x509_extensions = req_extensions |
| 177 | |
| 178 | [ req_distinguished_name ] |
| 179 | organizationName = $ORG_NAME |
| 180 | organizationalUnitName = $ORG_UNIT_NAME Server Farm |
| 181 | |
| 182 | [ policy_match ] |
| 183 | countryName = optional |
| 184 | stateOrProvinceName = optional |
| 185 | organizationName = match |
| 186 | organizationalUnitName = optional |
| 187 | commonName = supplied |
| 188 | |
| 189 | [ req_extensions ] |
| 190 | basicConstraints = CA:false |
| 191 | subjectKeyIdentifier = hash |
| 192 | authorityKeyIdentifier = keyid:always, issuer |
| 193 | keyUsage = digitalSignature, keyEncipherment, keyAgreement |
| 194 | extendedKeyUsage = serverAuth, clientAuth |
| 195 | subjectAltName = \$ENV::SUBJECT_ALT_NAME |
| 196 | |
| 197 | " >$ca_dir/signing.conf |
| 198 | } |
| 199 | |
Dean Troyer | ca80217 | 2013-01-09 19:08:02 -0600 | [diff] [blame] | 200 | # Create root and intermediate CAs |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 201 | # init_CA |
| 202 | function init_CA { |
| 203 | # Ensure CAs are built |
| 204 | make_root_CA $ROOT_CA_DIR |
| 205 | make_int_CA $INT_CA_DIR $ROOT_CA_DIR |
| 206 | |
| 207 | # Create the CA bundle |
| 208 | cat $ROOT_CA_DIR/cacert.pem $INT_CA_DIR/cacert.pem >>$INT_CA_DIR/ca-chain.pem |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 209 | cat $INT_CA_DIR/ca-chain.pem >> $SSL_BUNDLE_FILE |
| 210 | |
| 211 | if is_fedora; then |
| 212 | sudo cp $INT_CA_DIR/ca-chain.pem /usr/share/pki/ca-trust-source/anchors/devstack-chain.pem |
| 213 | sudo update-ca-trust |
| 214 | elif is_ubuntu; then |
| 215 | sudo cp $INT_CA_DIR/ca-chain.pem /usr/local/share/ca-certificates/devstack-int.crt |
| 216 | sudo cp $ROOT_CA_DIR/cacert.pem /usr/local/share/ca-certificates/devstack-root.crt |
| 217 | sudo update-ca-certificates |
| 218 | fi |
| 219 | } |
| 220 | |
| 221 | # Clean up the CA files |
| 222 | # cleanup_CA |
| 223 | function cleanup_CA { |
| 224 | if is_fedora; then |
| 225 | sudo rm -f /usr/share/pki/ca-trust-source/anchors/devstack-chain.pem |
| 226 | sudo update-ca-trust |
| 227 | elif is_ubuntu; then |
| 228 | sudo rm -f /usr/local/share/ca-certificates/devstack-int.crt |
| 229 | sudo rm -f /usr/local/share/ca-certificates/devstack-root.crt |
| 230 | sudo update-ca-certificates |
| 231 | fi |
Dean Troyer | ca80217 | 2013-01-09 19:08:02 -0600 | [diff] [blame] | 232 | } |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 233 | |
Dean Troyer | ca80217 | 2013-01-09 19:08:02 -0600 | [diff] [blame] | 234 | # Create an initial server cert |
| 235 | # init_cert |
| 236 | function init_cert { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 237 | if [[ ! -r $DEVSTACK_CERT ]]; then |
| 238 | if [[ -n "$TLS_IP" ]]; then |
| 239 | # Lie to let incomplete match routines work |
| 240 | TLS_IP="DNS:$TLS_IP" |
| 241 | fi |
| 242 | make_cert $INT_CA_DIR $DEVSTACK_CERT_NAME $DEVSTACK_HOSTNAME "$TLS_IP" |
| 243 | |
| 244 | # Create a cert bundle |
| 245 | cat $INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key $INT_CA_DIR/$DEVSTACK_CERT_NAME.crt $INT_CA_DIR/cacert.pem >$DEVSTACK_CERT |
| 246 | fi |
| 247 | } |
| 248 | |
| 249 | |
| 250 | # make_cert creates and signs a new certificate with the given commonName and CA |
| 251 | # make_cert ca-dir cert-name "common-name" ["alt-name" ...] |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 252 | function make_cert { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 253 | local ca_dir=$1 |
| 254 | local cert_name=$2 |
| 255 | local common_name=$3 |
| 256 | local alt_names=$4 |
| 257 | |
Stanislaw Pitucha | 2f69c6b | 2014-06-25 15:07:48 +0100 | [diff] [blame] | 258 | # Only generate the certificate if it doesn't exist yet on the disk |
| 259 | if [ ! -r "$ca_dir/$cert_name.crt" ]; then |
| 260 | # Generate a signing request |
| 261 | $OPENSSL req \ |
| 262 | -sha1 \ |
| 263 | -newkey rsa \ |
| 264 | -nodes \ |
| 265 | -keyout $ca_dir/private/$cert_name.key \ |
| 266 | -out $ca_dir/$cert_name.csr \ |
| 267 | -subj "/O=${ORG_NAME}/OU=${ORG_UNIT_NAME} Servers/CN=${common_name}" |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 268 | |
Stanislaw Pitucha | 2f69c6b | 2014-06-25 15:07:48 +0100 | [diff] [blame] | 269 | if [[ -z "$alt_names" ]]; then |
| 270 | alt_names="DNS:${common_name}" |
| 271 | else |
| 272 | alt_names="DNS:${common_name},${alt_names}" |
| 273 | fi |
| 274 | |
| 275 | # Sign the request valid for 1 year |
| 276 | SUBJECT_ALT_NAME="$alt_names" \ |
| 277 | $OPENSSL ca -config $ca_dir/signing.conf \ |
| 278 | -extensions req_extensions \ |
| 279 | -days 365 \ |
| 280 | -notext \ |
| 281 | -in $ca_dir/$cert_name.csr \ |
| 282 | -out $ca_dir/$cert_name.crt \ |
| 283 | -subj "/O=${ORG_NAME}/OU=${ORG_UNIT_NAME} Servers/CN=${common_name}" \ |
| 284 | -batch |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 285 | fi |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | |
| 289 | # Make an intermediate CA to sign everything else |
| 290 | # make_int_CA ca-dir signing-ca-dir |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 291 | function make_int_CA { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 292 | local ca_dir=$1 |
| 293 | local signing_ca_dir=$2 |
| 294 | |
| 295 | # Create the root CA |
| 296 | create_CA_base $ca_dir |
| 297 | create_CA_config $ca_dir 'Intermediate CA' |
| 298 | create_signing_config $ca_dir |
| 299 | |
Stanislaw Pitucha | 2f69c6b | 2014-06-25 15:07:48 +0100 | [diff] [blame] | 300 | if [ ! -r "$ca_dir/cacert.pem" ]; then |
| 301 | # Create a signing certificate request |
| 302 | $OPENSSL req -config $ca_dir/ca.conf \ |
| 303 | -sha1 \ |
| 304 | -newkey rsa \ |
| 305 | -nodes \ |
| 306 | -keyout $ca_dir/private/cacert.key \ |
| 307 | -out $ca_dir/cacert.csr \ |
| 308 | -outform PEM |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 309 | |
Stanislaw Pitucha | 2f69c6b | 2014-06-25 15:07:48 +0100 | [diff] [blame] | 310 | # Sign the intermediate request valid for 1 year |
| 311 | $OPENSSL ca -config $signing_ca_dir/ca.conf \ |
| 312 | -extensions ca_extensions \ |
| 313 | -days 365 \ |
| 314 | -notext \ |
| 315 | -in $ca_dir/cacert.csr \ |
| 316 | -out $ca_dir/cacert.pem \ |
| 317 | -batch |
| 318 | fi |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | # Make a root CA to sign other CAs |
| 322 | # make_root_CA ca-dir |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 323 | function make_root_CA { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 324 | local ca_dir=$1 |
| 325 | |
| 326 | # Create the root CA |
| 327 | create_CA_base $ca_dir |
| 328 | create_CA_config $ca_dir 'Root CA' |
| 329 | |
| 330 | # Create a self-signed certificate valid for 5 years |
| 331 | $OPENSSL req -config $ca_dir/ca.conf \ |
| 332 | -x509 \ |
| 333 | -nodes \ |
| 334 | -newkey rsa \ |
| 335 | -days 21360 \ |
| 336 | -keyout $ca_dir/private/cacert.key \ |
| 337 | -out $ca_dir/cacert.pem \ |
| 338 | -outform PEM |
| 339 | } |
| 340 | |
| 341 | |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 342 | # Certificate Input Configuration |
| 343 | # =============================== |
| 344 | |
| 345 | # check to see if the service(s) specified are to be SSL enabled. |
| 346 | # |
| 347 | # Multiple services specified as arguments are ``OR``'ed together; the test |
| 348 | # is a short-circuit boolean, i.e it returns on the first match. |
| 349 | # |
| 350 | # Uses global ``SSL_ENABLED_SERVICES`` |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 351 | function is_ssl_enabled_service { |
Sean Dague | f0bd8db | 2014-07-23 15:14:07 -0400 | [diff] [blame] | 352 | local services=$@ |
| 353 | local service="" |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 354 | if [ "$USE_SSL" == "False" ]; then |
| 355 | return 1 |
| 356 | fi |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 357 | for service in ${services}; do |
| 358 | [[ ,${SSL_ENABLED_SERVICES}, =~ ,${service}, ]] && return 0 |
| 359 | done |
| 360 | return 1 |
| 361 | } |
| 362 | |
| 363 | |
| 364 | # Ensure that the certificates for a service are in place. This function does |
| 365 | # not check that a service is SSL enabled, this should already have been |
| 366 | # completed. |
| 367 | # |
| 368 | # The function expects to find a certificate, key and CA certificate in the |
| 369 | # variables {service}_SSL_CERT, {service}_SSL_KEY and {service}_SSL_CA. For |
| 370 | # example for keystone this would be KEYSTONE_SSL_CERT, KEYSTONE_SSL_KEY and |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 371 | # KEYSTONE_SSL_CA. |
| 372 | # |
| 373 | # If it does not find these certificates then the devstack-issued server |
| 374 | # certificate, key and CA certificate will be associated with the service. |
| 375 | # |
| 376 | # If only some of the variables are provided then the function will quit. |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 377 | function ensure_certificates { |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 378 | local service=$1 |
| 379 | |
| 380 | local cert_var="${service}_SSL_CERT" |
| 381 | local key_var="${service}_SSL_KEY" |
| 382 | local ca_var="${service}_SSL_CA" |
| 383 | |
| 384 | local cert=${!cert_var} |
| 385 | local key=${!key_var} |
| 386 | local ca=${!ca_var} |
| 387 | |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 388 | if [[ -z "$cert" && -z "$key" && -z "$ca" ]]; then |
| 389 | local cert="$INT_CA_DIR/$DEVSTACK_CERT_NAME.crt" |
| 390 | local key="$INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key" |
| 391 | local ca="$INT_CA_DIR/ca-chain.pem" |
| 392 | eval ${service}_SSL_CERT=\$cert |
| 393 | eval ${service}_SSL_KEY=\$key |
| 394 | eval ${service}_SSL_CA=\$ca |
| 395 | return # the CA certificate is already in the bundle |
| 396 | elif [[ -z "$cert" || -z "$key" || -z "$ca" ]]; then |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 397 | die $LINENO "Missing either the ${cert_var} ${key_var} or ${ca_var}" \ |
| 398 | "variable to enable SSL for ${service}" |
| 399 | fi |
| 400 | |
| 401 | cat $ca >> $SSL_BUNDLE_FILE |
| 402 | } |
| 403 | |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 404 | # Enable the mod_ssl plugin in Apache |
| 405 | function enable_mod_ssl { |
| 406 | echo "Enabling mod_ssl" |
| 407 | |
| 408 | if is_ubuntu; then |
| 409 | sudo a2enmod ssl |
| 410 | elif is_fedora; then |
| 411 | # Fedora enables mod_ssl by default |
| 412 | : |
| 413 | fi |
| 414 | if ! sudo `which httpd || which apache2ctl` -M | grep -w -q ssl_module; then |
| 415 | die $LINENO "mod_ssl is not enabled in apache2/httpd, please check for it manually and run stack.sh again" |
| 416 | fi |
| 417 | } |
| 418 | |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 419 | |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 420 | # Proxy Functions |
| 421 | # =============== |
| 422 | |
| 423 | # Starts the TLS proxy for the given IP/ports |
| 424 | # start_tls_proxy front-host front-port back-host back-port |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 425 | function start_tls_proxy { |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 426 | local f_host=$1 |
| 427 | local f_port=$2 |
| 428 | local b_host=$3 |
| 429 | local b_port=$4 |
| 430 | |
| 431 | stud $STUD_PROTO -f $f_host,$f_port -b $b_host,$b_port $DEVSTACK_CERT 2>/dev/null |
| 432 | } |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 433 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 434 | |
Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 435 | # Cleanup Functions |
Dean Troyer | 3324f19 | 2014-09-18 09:26:39 -0500 | [diff] [blame] | 436 | # ================= |
Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 437 | |
| 438 | |
| 439 | # Stops all stud processes. This should be done only after all services |
| 440 | # using tls configuration are down. |
| 441 | function stop_tls_proxy { |
| 442 | killall stud |
| 443 | } |
| 444 | |
| 445 | |
| 446 | # Remove CA along with configuration, as well as the local server certificate |
| 447 | function cleanup_CA { |
| 448 | rm -rf "$DATA_DIR/CA" "$DEVSTACK_CERT" |
| 449 | } |
| 450 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 451 | # Tell emacs to use shell-script-mode |
| 452 | ## Local variables: |
| 453 | ## mode: shell-script |
| 454 | ## End: |