- can't figure out how to parse escaped colons in gpg --with-colons
[myplc.git] / plc.d / ssl
index c813f99..fc3fa74 100755 (executable)
--- a/plc.d/ssl
+++ b/plc.d/ssl
@@ -7,11 +7,12 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $
+# $Id: ssl,v 1.3 2006/04/07 04:28:16 mlhuang Exp $
 #
 
 # Source function library and configuration
 . /etc/plc.d/functions
+. /etc/planetlab/plc_config
 
 case "$1" in
     start)
@@ -46,14 +47,6 @@ case "$1" in
                fi
            done
 
-           # Generate new SSL private key
-           if [ ! -f ${!ssl_key} ] ; then
-               mkdir -p $(dirname ${!ssl_key})
-               openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 >${!ssl_key}
-               check
-               chmod 600 ${!ssl_key}
-           fi
-
            # Check if self signed certificate is valid
            if [ -f ${!ssl_crt} ] ; then
                verify=$(openssl verify ${!ssl_crt})
@@ -73,15 +66,8 @@ case "$1" in
            if [ ! -f ${!ssl_crt} ] ; then
                mkdir -p $(dirname ${!ssl_crt})
                openssl req -new -x509 -days 365 -set_serial $RANDOM \
-                   -key ${!ssl_key} -out ${!ssl_crt} <<EOF
---
-State
-City
-Organization
-$PLC_NAME Central
-${!hostname}
-$PLC_MAIL_SUPPORT_ADDRESS
-EOF
+                   -batch -subj "/CN=${!hostname}" \
+                   -nodes -keyout ${!ssl_key} -out ${!ssl_crt}
                check
                chmod 644 ${!ssl_crt}
            fi