summaryrefslogtreecommitdiff
path: root/vchat-keygen
diff options
context:
space:
mode:
authorerdgeist <>2003-02-12 17:48:37 +0000
committererdgeist <>2003-02-12 17:48:37 +0000
commitdea6bf757aa9a875eab35b2b650412e7605f1308 (patch)
tree14ed8374c3a3862529313088375693a7de70d3a7 /vchat-keygen
CVS moved to erdgeist.org
Diffstat (limited to 'vchat-keygen')
-rwxr-xr-xvchat-keygen156
1 files changed, 156 insertions, 0 deletions
diff --git a/vchat-keygen b/vchat-keygen
new file mode 100755
index 0000000..08c3b6e
--- /dev/null
+++ b/vchat-keygen
@@ -0,0 +1,156 @@
1#!/bin/sh
2
3#
4# vchat-client - alpha version
5# vchat-keygen - generate keypair for SSL with anon CA
6#
7# Copyright (C) 2001 Andreas Kotes <count@flatline.de>
8#
9# This program is free software. It can be redistributed and/or modified,
10# provided that this copyright notice is kept intact. This program is
11# distributed in the hope that it will be useful, but without any warranty;
12# without even the implied warranty of merchantability or fitness for a
13# particular purpose. In no event shall the copyright holder be liable for
14# any direct, indirect, incidental or special damages arising in any way out
15# of the use of this software.
16#
17
18# where do we want to store the key?
19KEYBASE=$1
20if [ "x$KEYBASE" = "x" ] ; then
21 KEYBASE=$HOME/.vchat
22fi
23
24# no key? generate one ...
25if [ ! -e $KEYBASE.key ]; then
26 echo "vchat-keygen: generating RSA key $KEYBASE.key"
27 echo "vchat-keygen: please set passphrase for local security"
28 umask 0077
29 openssl genrsa -des3 -out $KEYBASE.key 2048
30else
31 echo "vchat-keygen: private key $KEYBASE.key exists"
32fi
33
34# no certificate? dump anonymous CA to disk.
35if [ ! -e $KEYBASE.cert ]; then
36 if [ ! -e $KEYBASE.ca.key ]; then
37 echo "vchat-keygen: saving CA key to $KEYBASE.ca.key"
38 cat >$KEYBASE.ca.key <<EOT
39-----BEGIN RSA PRIVATE KEY-----
40MIIEowIBAAKCAQEA0OydKPwRccotlfz4ZhKrVM1vbRa9bWOfZ1c4C6J+iLmZMjuk
41uALo5+c72phZjJ8qXTY+j+J4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goQRAZuktKwu+Jn1Hm
588SvIPXqW5yBsg4XW+Izk9QXdp4XwFXXooQiUvZtHryC8w+cjC85ag8RMMpesp1ZY
590p7Scrm/PAOmKEycZvkGS2ECgYAWYIjZ2i0Op8pUJixedZ8jr5OEqyzHGkoKk/wg
60u8Wu6Uvmpnbk8lxkcnfwGUAwFcmpZtVlQFR7L28LmmkNr/m6RU2JEgzzN8eMxa66
61nYQn1EBnnWzK1qehnAHap8MRiFJ04E4QfbCm5wOTY1c7Xr73Xp9+L9UbNYSyybL8
62Nuh+yQKBgHUJf3RslTr382pFcHxXNQpA5wQHhtuL+VacbddnZNZCflQoJ+Zk1/GV
630fDgfrY1+LVQvo/rpm6N3FIdLSaFwn2OmZMIwLWfu4BL1NNdWMwjSWkQ8hToVe5e
64707+ARBWPZX0GfZXHUybrZDJNlT01brqo4DhlWxMCPrAj3XNY6yr
65-----END RSA PRIVATE KEY-----
66EOT
67 fi
68 if [ ! -e $KEYBASE.ca.crt ]; then
69 echo "vchat-keygen: saving CA cert to $KEYBASE.ca.crt"
70 cat >$KEYBASE.ca.crt <<EOT
71-----BEGIN CERTIFICATE-----
72MIIC4zCCAcugAwIBAgIBADANBgkqhkiG9w0BAQQFADAbMRkwFwYDVQQDExBBbm9u
73eW1vdXMgRk9PIENBMB4XDTAxMDcwOTE0MzAyM1oXDTExMDcwNzE0MzAyM1owGzEZ
74MBcGA1UEAxMQQW5vbnltb3VzIEZPTyBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP
75ADCCAQoCggEBANDsnSj8EXHKLZX8+GYSq1TNb20WvW1jn2dXOAuifoi5mTI7pLgC
766OfnO9qYWYyfKl02Po/ieH6EV4AQ96jcAxY7R2g7auKSu9FgFke/oLZ06FY7yJ4K
77vvh7fNhkECt+ECgQYeFP7HUtar0FjZFuv7Q2utaUcByPcUYVxt2JlaxNJqbP6CaG
78ksUEKZPup047qn2xR/iRKs2IFyy2JubGd3kbgpQns5kPWtR0hlviTOIi+8XUS7vK
79NTJez2oTgyK/wm+JynKPIKyfoJeAoSPlfFbFDXJpqF3bW+29Me7QjnL6dkzyBFSt
80LDEwwpbRr1wypNz6y/prAAEyYQPdBVU1IzkCAwEAAaMyMDAwDwYDVR0TAQH/BAUw
81AwEB/zAdBgNVHQ4EFgQUFsM7fh5NPHIgbUBsGqp+IAH4AjIwDQYJKoZIhvcNAQEE
82BQADggEBALKjPE9OX+FrKOODs+d4P/QJdEwsTKwT3zHjxUTKmhIRE1qphAiEfH2g
83IMgr/7y4MZd7FIx84qrfA+a96Yyb5QdbRu0fGlkom1JZxkKOQ2T5SiX7iU2nXMLa
84tsFoqKwrjG4vWwN8ZrlLT72+fZGTtFCUQm7pTxd7UZcfIcmfE43OJGl155gd2X8j
85jbbyu/lBwdJXznK86cm++lvXYJTeJEybipX/XoGoJtCZq0dGyC7vBTGnBZGmNymQ
861QHQ8LjnzGK3q1ccLuGZ9QjXOjMImfPXGxiXMHO63Ph27U3jP4LEBsW3iRaUqevY
87Id4rGHl2/jBQyE1CGeN1o9iZBGmFS1c=
88-----END CERTIFICATE-----
89EOT
90 fi
91 if [ -e /tmp/00.pem ]; then
92 echo "vchat-keygen: insecure files lying around, bailing out"
93 exit
94 fi
95 if [ ! -e $KEYBASE.ca.conf ]; then
96 echo "vchat-keygen: generating config-file for CA $KEYBASE.ca.conf"
97 cat >$KEYBASE.ca.conf <<EOT
98[ ca ]
99default_ca = default_CA
100[ default_CA ]
101dir = .
102#certs = \$dir
103new_certs_dir = /tmp
104database = $KEYBASE.ca.db.index
105serial = $KEYBASE.ca.db.serial
106certificate = $KEYBASE.ca.crt
107private_key = $KEYBASE.ca.key
108default_days = 1825
109default_crl_days = 30
110default_md = md5
111preserve = no
112x509_extensions = user_cert
113policy = policy_anything
114[ policy_anything ]
115commonName = supplied
116emailAddress = supplied
117[ user_cert ]
118basicConstraints = critical,CA:false
119authorityKeyIdentifier = keyid:always
120extendedKeyUsage = clientAuth
121EOT
122 echo -n >$KEYBASE.ca.db.index
123 echo 00 >$KEYBASE.ca.db.serial
124 fi
125 if [ ! -e $KEYBASE.csr ]; then
126 if [ ! -e $KEYBASE.ca.keyconf ]; then
127 echo "vchat-keygen: generating config-file for self-signing $KEYBASE.ca.keyconf"
128 cat >$KEYBASE.ca.keyconf <<EOT
129[ req ]
130default_bits = 2048
131default_keyfile = user.key
132distinguished_name = req_distinguished_name
133string_mask = nombstr
134req_extensions = v3_req
135[ req_distinguished_name ]
136commonName = Name
137commonName_max = 64
138emailAddress = Email Address
139emailAddress_max = 40
140[ v3_req ]
141nsCertType = client
142basicConstraints = critical,CA:false
143EOT
144 fi
145 echo "vchat-keygen: generating Certificate Signing Request $KEYBASE.csr"
146 openssl req -new -config $KEYBASE.ca.keyconf -key $KEYBASE.key -out $KEYBASE.csr
147 else
148 echo "vchat-keygen: Certificate Signing Request $KEYBASE.csr exists"
149 fi
150 echo "vchat-keygen: signing certificate $KEYBASE.cert"
151 openssl ca -batch -config $KEYBASE.ca.conf -out $KEYBASE.cert -in $KEYBASE.csr
152 rm /tmp/00.pem $KEYBASE.ca.*
153 echo
154else
155 echo "vchat-keygen: certificate $KEYBASE.cert exists"
156fi