Permalink
Browse files

Added "gencerts" command to siriproxy bin to generate certificates

-Updated gen_certs.zsh to be "gen_certs.sh"
-Updated gen_certs.sh to be free of user interaction, use better temp directories, and have cleaner output
  • Loading branch information...
1 parent a869d1c commit c20295f551942eb8dc7c51e8692584912379a970 @plamoni plamoni committed Nov 27, 2011
Showing with 440 additions and 33 deletions.
  1. +9 −0 ca.args
  2. +74 −0 gen_certs.sh
  3. +0 −33 gen_certs.zsh
  4. +7 −0 lib/siriproxy/command_line.rb
  5. +350 −0 openssl.cnf
View
@@ -0,0 +1,9 @@
+US
+Missouri
+
+Siri Proxy
+
+guzzoni.apple.com
+
+
+
View
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+
+# Feel free to change any of these defaults
+countryName="US"
+stateOrProvinceName="Missouri"
+localityName=""
+organizationName="Siri Proxy"
+organizationalUnitName=""
+commonName="SiriProxyCA"
+emailAddress=""
+
+#You probably don't need to modify these unless you know what you're doing.
+SIRI_PROXY_SETTINGS=~/.siriproxy
+LOG_FILE=$SIRI_PROXY_SETTINGS/cert.log
+TMP_DIR=/tmp
+TMP_CA_DIR=/tmp/siriCA #THIS ($dir) ALSO MUST BE MODIFIED IN openssl.cnf IF YOU CHANGE IT!
+
+## Do not edit below here!
+
+echo "" > $LOG_FILE
+
+echo "Creating CA directory"
+mkdir -p $TMP_CA_DIR/{certs,crl,newcerts,private}
+touch $TMP_CA_DIR/index.txt
+echo 01 > $TMP_CA_DIR/crtnumber
+
+echo "Generating '${commonName}' CA request"
+echo "${countryName}" > $TMP_DIR/ca.args
+echo "${stateOrProvinceName}" >> $TMP_DIR/ca.args
+echo "${localityName}" >> $TMP_DIR/ca.args
+echo "${organizationName}" >> $TMP_DIR/ca.args
+echo "${organizationalUnitName}" >> $TMP_DIR/ca.args
+echo "${commonName}" >> $TMP_DIR/ca.args
+echo "${emailAddress}" >> $TMP_DIR/ca.args
+echo "" >> $TMP_DIR/ca.args
+echo "" >> $TMP_DIR/ca.args
+
+cat $TMP_DIR/ca.args | openssl req -new -config ./openssl.cnf -keyout $TMP_CA_DIR/private/cakey.pem -out $TMP_CA_DIR/careq.pem -passin pass:1234 -passout pass:1234 >> $LOG_FILE 2>> $LOG_FILE
+
+echo "Self-signing '${commonName}' CA"
+openssl ca -create_serial -passin pass:1234 -config ./openssl.cnf -out $TMP_CA_DIR/cacert.pem -outdir $TMP_CA_DIR/newcerts -days 1095 -batch -keyfile $TMP_CA_DIR/private/cakey.pem -selfsign -extensions v3_ca -infiles $TMP_CA_DIR/careq.pem >> $LOG_FILE 2>> $LOG_FILE
+
+echo "Generating guzzoni.apple.com certificate request"
+echo "Generating '${commonName}' CA request"
+echo "${countryName}" > $TMP_DIR/ca.args
+echo "${stateOrProvinceName}" >> $TMP_DIR/ca.args
+echo "${localityName}" >> $TMP_DIR/ca.args
+echo "${organizationName}" >> $TMP_DIR/ca.args
+echo "${organizationalUnitName}" >> $TMP_DIR/ca.args
+echo "guzzoni.apple.com" >> $TMP_DIR/ca.args
+echo "${emailAddress}" >> $TMP_DIR/ca.args
+echo "" >> $TMP_DIR/ca.args
+echo "" >> $TMP_DIR/ca.args
+cat $TMP_DIR/ca.args | openssl req -new -keyout $TMP_DIR/newkey.pem -config ./openssl.cnf -out $TMP_DIR/newreq.pem -days 1095 -passin pass:1234 -passout pass:1234 >> $LOG_FILE 2>> $LOG_FILE
+
+echo "Generating guzzoni.apple.com certificate"
+yes | openssl ca -policy policy_anything -out $TMP_DIR/newcert.pem -config ./openssl.cnf -passin pass:1234 -keyfile $TMP_CA_DIR/private/cakey.pem -cert $TMP_CA_DIR/cacert.pem -infiles $TMP_DIR/newreq.pem >> $LOG_FILE 2>> $LOG_FILE
+
+echo "Removing passphrase from guzzoni.apple.com key"
+yes | openssl rsa -in $TMP_DIR/newkey.pem -out $SIRI_PROXY_SETTINGS/server.passless.key -passin pass:1234 >> $LOG_FILE 2>> $LOG_FILE
+
+echo "Cleaning up..."
+mv $TMP_DIR/newcert.pem $SIRI_PROXY_SETTINGS/server.passless.crt
+mv $TMP_CA_DIR/cacert.pem $SIRI_PROXY_SETTINGS/ca.pem
+rm -rf $TMP_DIR/new{key,req}.pem $TMP_CA_DIR $TMP_DIR/ca.args
+
+echo "Done! (For details on any errors, check '${LOG_FILE}')"
+echo "-------------------------------------------------------------"
+echo ""
+echo "Please install ${SIRI_PROXY_SETTINGS}/ca.pem onto your phone!"
+echo "(Note: You can do this by emailing the file to yourself)"
+echo ""
+echo "-------------------------------------------------------------"
View
@@ -1,33 +0,0 @@
-#!/usr/bin/env zsh
-
-
-# Feel free to change any of these defaults
-countryName="UK"
-stateOrProvinceName="England"
-localityName=""
-organizationName="Siri Proxy"
-organizationalUnitName=""
-commonName="SiriProxy"
-emailAddress=""
-
-## Do not edit below here!
-echo "Ok, before we get going you need to know a few things"
-echo "You're about to be asked four questions, the answers are: 1234, 1234, y, y"
-echo -n "Hit return to continue!"; read -e
-
-mkdir -p demoCA/{certs,crl,newcerts,private}
-touch demoCA/index.txt
-echo 01 > demoCA/crtnumber
-
-CAREQARGS="${countryName}\n${stateOrProvinceName}\n${localityName}\n${organizationName}\n${organizationalUnitName}\n${commonName}\n${emailAddress}\n\n\n"
-echo -n $CAREQARGS | openssl req -new -keyout demoCA/private/cakey.pem -out demoCA/careq.pem -passin pass:1234 -passout pass:1234
-openssl ca -create_serial -out demoCA/cacert.pem -days 1095 -batch -keyfile demoCA/private/cakey.pem -selfsign -extensions v3_ca -infiles demoCA/careq.pem
-
-CRTREQARGS="${countryName}\n${stateOrProvinceName}\n${localityName}\n${organizationName}\n${organizationalUnitName}\nguzzoni.apple.com\n${emailAddress}\n\n\n"
-echo $CRTREQARGS | openssl req -new -keyout newkey.pem -out newreq.pem -days 1095 -passin pass:1234 -passout pass:1234
-openssl ca -policy policy_anything -out newcert.pem -infiles newreq.pem
-openssl rsa -in newkey.pem -out server.passless.key -passin pass:1234
-
-mv newcert.pem server.passless.crt
-mv demoCA/cacert.pem ca.pem
-rm -rf new{key,req}.pem demoCA
@@ -19,6 +19,7 @@ class SiriProxy::CommandLine
Commands:
server Start up the Siri proxy server
+gencerts Generate a the certificates needed for SiriProxy
bundle Install any dependancies needed by plugins
console Launch the plugin test console
help Show this usage information
@@ -32,6 +33,7 @@ def initialize
subcommand = ARGV.shift
case command
when 'server' then run_server(subcommand)
+ when 'gencerts' then gen_certs
when 'bundle' then run_bundle
when 'console' then run_console
when 'help' then usage
@@ -65,6 +67,11 @@ def start_server
proxy.start()
end
+ def gen_certs
+ command = File.join(File.dirname(__FILE__), '..', "..", 'gen_certs.sh')
+ puts `#{command}`
+ end
+
def usage
puts "\n#{@option_parser}\n"
end
Oops, something went wrong.

0 comments on commit c20295f

Please sign in to comment.