5 # minimal script for initializing SSL material for myslice
6 # you probably want to take care of this yourself instead,
7 # but until somebody gets around to that apache will at least start up
9 trusted_roots=/etc/unfold/trusted_roots
10 key=/etc/unfold/myslice.key
11 cert=/etc/unfold/myslice.cert
13 # provide a hostname as the first arg to this command
14 # (otherwise we use hostname)
15 if [[ -n "$@" ]] ; then hostname=$1; shift; else hostname=$(hostname); fi
17 function init_trusted_roots () {
18 if [ ! -d $trusted_roots ] ; then
19 echo "Creating empty" $trusted_roots
20 mkdir -p $trusted_roots
21 echo "You will wish to populate that with e.g. ple.gid or the like"
22 echo "Make sure to re-run this command $COMMAND if you add gids"
24 ### c_rehash will consider only files ending in .pem or .crt
25 # so, we create symlinks from *.gid to *.pem
26 pushd $trusted_roots >& /dev/null
28 base=$(basename $gid .gid)
30 [ -f $pem ] && ln -s $gid $pem
33 # on debian c_rehash comes with openssl
34 # on fedora this is part of openssl-perl
35 echo -n "Invoking c_rehash in $(pwd) .. "; c_rehash .
39 function init_server_cert () {
40 # both present : we have nothing to do
41 [ -f $key -a -f $cert ] && return
42 # exactly one present : we have a problem
43 [ -f $key -o -f $cert ] && { echo "server key or cert missing ?!?" ; return ; }
45 echo "Creating server key and cert for hostname ${hostname}"
46 openssl req -new -x509 -days 365 -set_serial $RANDOM -batch \
47 -subj "/CN=${hostname}" -nodes -keyout $key -out $cert