aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport-certificate-creation.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-transport-certificate-creation.in')
-rw-r--r--src/transport/gnunet-transport-certificate-creation.in158
1 files changed, 0 insertions, 158 deletions
diff --git a/src/transport/gnunet-transport-certificate-creation.in b/src/transport/gnunet-transport-certificate-creation.in
deleted file mode 100644
index 771422a7a..000000000
--- a/src/transport/gnunet-transport-certificate-creation.in
+++ /dev/null
@@ -1,158 +0,0 @@
1#!/bin/sh
2#
3# This shell script will generate an X509 certificate for
4# your gnunet-transport HTTPS
5#
6# The current version partially reuses and recycles
7# code from build.sh by NetBSD (although not entirely
8# used because it needs debugging):
9#
10# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
11# All rights reserved.
12#
13# This code is derived from software contributed to
14# The NetBSD Foundation by Todd Vierling and Luke Mewburn.
15
16# Redistribution and use in source and binary forms, with or
17# without modification, are permitted provided that the following
18# conditions are met:
19# 1. Redistributions of source code must retain the above
20# copyright notice, this list of conditions and the following
21# disclaimer.
22# 2. Redistributions in binary form must reproduce the above
23# copyright notice, this list of conditions and the following
24# disclaimer in the documentation and/or other materials
25# provided with the distribution.
26
27# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
28# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
29# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31# DISCLAIMED.
32# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR
33# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38# LIABILITY, OR TORT
39# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
40# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41# OF SUCH DAMAGE.
42
43progname=${0##*/}
44
45existence() {
46 command -v "$1" >/dev/null 2>&1
47}
48
49setdefaults()
50{
51 verbosity=0
52 runcmd=
53}
54
55statusmsg()
56{
57 ${runcmd} echo " $@"
58}
59
60infomsg()
61{
62 if [ x$verbosity = x1 ]; then
63 statusmsg "INFO: $@"
64 fi
65}
66
67warningmsg()
68{
69 statusmsg "WARNING: $@"
70}
71
72errormsg()
73{
74 statusmsg "ERROR: $@"
75}
76
77linemsg()
78{
79 statusmsg "========================================="
80}
81
82
83usage()
84{
85 if [ -n "$*" ]; then
86 echo ""
87 echo "${progname}: $*"
88 fi
89 cat <<_usage_
90
91Usage: ${progname} [-hv] [-c FILE] [...]
92
93Options:
94 -c FILE Use the configuration file FILE.
95 -h Print this help message.
96 -v Print the version and exit.
97 -V be verbose
98
99_usage_
100 exit 1
101}
102
103
104generate_cert_key()
105{
106 echo ""
107 infomsg "Generating Cert and Key"
108
109 CERTTOOL=""
110 GNUTLS_CA_TEMPLATE=@PKGDATADIRECTORY@/gnunet-gns-proxy-ca.template
111 OPENSSL=0
112 if test -x $(existence gnutls-certtool)
113 #if test -z "`gnutls-certtool --version`" > /dev/null
114 then
115 if test -z "`certtool --version | grep gnutls`" > /dev/null
116 then
117 warningmsg "'gnutls-certtool' or 'certtool' command not found. Trying openssl."
118 # if test -z "`openssl version`" > /dev/null
119 if test -x $(existence openssl)
120 then
121 OPENSSL=1
122 else
123 warningmsg "Install either gnutls certtool or openssl for certificate generation!"
124 statusmsg "Cleaning up."
125 exit 1
126 fi
127 fi
128 CERTTOOL="certtool"
129 else
130 CERTTOOL="gnutls-certtool"
131 fi
132 mkdir -p `dirname $KEYFILE`
133
134 if test 1 -eq $OPENSSL
135 then
136 openssl genrsa -out $KEYFILE 1024
137 openssl req -batch -days 365 -out $CERTFILE -new -x509 -key $KEYFILE
138 else
139 $CERTTOOL --generate-privkey --outfile $KEYFILE 2>/dev/null
140 $CERTTOOL --template $GNUTLS_CA_TEMPLATE --generate-self-signed --load-privkey $KEYFILE --outfile $CERTFILE 2>/dev/null
141 fi
142 }
143
144print_version()
145{
146 GNUNET_ARM_VERSION=`gnunet-arm -v`
147 echo $GNUNET_ARM_VERSION
148}
149
150main()
151{
152 KEYFILE=$1
153 CERTFILE=$2
154 setdefaults
155 generate_cert_key
156}
157
158main "$@"