]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/sslScripts/openssl/opensslTest
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / sslScripts / openssl / opensslTest
1 #!/bin/csh
2 # openssl/certtool compatibility
3 #
4 # openssl file arguments
5 set CSR_FILE=new.cert.csr
6 set PRIV_KEY_ENCR=privkey.pem
7 set PRIV_RAW_KEY_PEM=new.key.pem
8 set CERT_FILE_PEM=new.cert.pem
9 set CERT_FILE_DER=new.cert.der
10 #
11 echo Preparing to delete $CSR_FILE $PRIV_KEY_ENCR $PRIV_RAW_KEY_PEM $CERT_FILE_PEM $CERT_FILE_DER
12 echo Ctl-c to abort, or....
13 doprompt
14 rm -f $CSR_FILE $PRIV_KEY_ENCR $PRIV_RAW_KEY_PEM $CERT_FILE_PEM $CERT_FILE_DER
15 #
16 # 1. Create the key and request. This will require
17 # some user interaction.
18 #
19 set cmd="openssl req -new"
20 echo $cmd \> $CSR_FILE
21 $cmd > $CSR_FILE || exit(1)
22 echo ...$PRIV_KEY_ENCR contains encrypted signing key in PEM format.
23 #
24 # 2. Remove the passphrase from the key.
25 #
26 set cmd="openssl rsa -in $PRIV_KEY_ENCR -out $PRIV_RAW_KEY_PEM"
27 echo $cmd
28 $cmd || exit(1)
29 echo ...$PRIV_RAW_KEY_PEM contains raw signing key in PEM format.
30 #
31 # 3. Convert request into signed cert.
32 #
33 set cmd="openssl x509 -in $CSR_FILE -out $CERT_FILE_PEM -req -signkey $PRIV_RAW_KEY_PEM -days 365"
34 echo $cmd
35 $cmd || exit(1)
36 echo ...$CERT_FILE_PEM contains signing cert in PEM format.
37 #
38 # 4. convert cert to DER form for use by sslViewer
39 #
40 set cmd="openssl x509 -inform PEM -outform DER -in $CERT_FILE_PEM -out $CERT_FILE_DER"
41 echo $cmd
42 $cmd || exit(1)
43 echo ...$CERT_FILE_DER contains cert in DER format.
44 #
45 echo preparing to run runServeView script. Ctl-c to abort, or....
46 doprompt
47 ./runServeView || exit(1)
48 #
49 echo === COMPLETE ===