[CalendarServer-changes] [1350]
CalendarServer/trunk/bin/make-ssl-key
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 8 14:37:34 PST 2007
Revision: 1350
http://trac.macosforge.org/projects/calendarserver/changeset/1350
Author: wsanchez at apple.com
Date: 2007-03-08 14:37:33 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
CalendarServer/trunk/bin/make-ssl-key
Added: CalendarServer/trunk/bin/make-ssl-key
===================================================================
--- CalendarServer/trunk/bin/make-ssl-key (rev 0)
+++ CalendarServer/trunk/bin/make-ssl-key 2007-03-08 22:37:33 UTC (rev 1350)
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+set -e
+set -u
+
+##
+# Handle command line
+##
+
+usage ()
+{
+ program=$(basename "$0");
+
+ if [ $# != 0 ]; then echo "$@"; echo ""; fi;
+
+ echo "usage: ${program} host_name";
+}
+
+if [ $# != 1 ]; then
+ usage;
+ exit 1;
+fi;
+
+host="$1";
+
+##
+# Do The Right Thing
+##
+
+newfile ()
+{
+ # New file is not readable and empty
+ name="$1";
+ rm -f "${name}";
+ tmp="$(mktemp "${name}")";
+ if [ "${tmp}" != "${name}" ]; then
+ mv "${tmp}" "${name}";
+ fi;
+}
+
+if [ ! -s "${host}.key" ]; then
+ echo "Generating host key...";
+ newfile "${host}.key.tmp";
+ openssl genrsa -des3 -out "${host}.key.tmp" 1024;
+ echo "";
+
+ echo "Removing pass phrase from key...";
+ newfile "${host}.key";
+ openssl rsa -in "${host}.key.tmp" -out "${host}.key";
+ rm "${host}.key.tmp";
+ echo "";
+else
+ echo "Key for ${host} already exists.";
+fi;
+
+if [ ! -s "${host}.csr" ]; then
+ echo "Generating certificate request...";
+ newfile "${host}.csr";
+ openssl req -new -key "${host}.key" -out "${host}.csr";
+ echo "";
+else
+ echo "Certificate request for ${host} already exists.";
+fi;
+
+if [ ! -s "${host}.crt" ]; then
+ echo "Generating certificate...";
+ openssl x509 -req -in "${host}.csr" -out "${host}.crt" -sha1 -CA ca.crt -CAkey ca.key -CAcreateserial -days 3650;
+ chmod 644 "${host}.crt";
+ echo "";
+else
+ echo "Certificate for ${host} already exists.";
+fi;
+
+# Print the certificate
+openssl x509 -in "${host}.crt" -text -noout;
Property changes on: CalendarServer/trunk/bin/make-ssl-key
___________________________________________________________________
Name: svn:executable
+ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070308/d9f4df99/attachment.html
More information about the calendarserver-changes
mailing list