aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-01 21:05:00 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-01 21:05:00 +0000
commita67bfb413b9da0ebaedc66caf7fe458771680601 (patch)
treea778138ce2e9f33267576971cc0ed8ca18498d85 /src
parentde5131875f4ee71b7b6fd21c3db59df1d55d1f3a (diff)
downloadgnunet-a67bfb413b9da0ebaedc66caf7fe458771680601.tar.gz
gnunet-a67bfb413b9da0ebaedc66caf7fe458771680601.zip
style
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_disk_lib.h5
-rw-r--r--src/transport/gnunet-transport-certificate-creation.c159
2 files changed, 86 insertions, 78 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index 383a9daa2..5403d256b 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -572,8 +572,9 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
572 * @return GNUNET_OK on success, GNUNET_SYSERR on error 572 * @return GNUNET_OK on success, GNUNET_SYSERR on error
573 */ 573 */
574int 574int
575GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, 575GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh,
576 off_t unlockEnd); 576 off_t unlockStart,
577 off_t unlockEnd);
577 578
578 579
579/** 580/**
diff --git a/src/transport/gnunet-transport-certificate-creation.c b/src/transport/gnunet-transport-certificate-creation.c
index 1256b93ba..c8fa62cc7 100644
--- a/src/transport/gnunet-transport-certificate-creation.c
+++ b/src/transport/gnunet-transport-certificate-creation.c
@@ -1,25 +1,51 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file transport/gnunet-transport-certificate-creation.c
23 * @brief create certificate for HTTPS transport
24 * @author LRN
25 *
26 */
1#include "platform.h" 27#include "platform.h"
2#include "gnunet_disk_lib.h" 28#include "gnunet_disk_lib.h"
3#include "gnunet_os_lib.h" 29#include "gnunet_os_lib.h"
4 30
5/* GNUnet TLS certificate shell scricpt
6 Creates a TSL certificate to use with HTTPS transport plugin
7*/
8 31
9void removecerts (char *file1, char *file2) 32static void
33removecerts (const char *file1,
34 const char *file2)
10{ 35{
11 if (GNUNET_DISK_file_test (file1) == GNUNET_YES) 36 if (GNUNET_DISK_file_test (file1) == GNUNET_YES)
12 { 37 {
13 CHMOD (file1, 0777); 38 CHMOD (file1, 0777);
14 REMOVE (file1); 39 REMOVE (file1);
15 } 40 }
16 if (GNUNET_DISK_file_test (file2) == GNUNET_YES) 41 if (GNUNET_DISK_file_test (file2) == GNUNET_YES)
17 { 42 {
18 CHMOD (file2, 0777); 43 CHMOD (file2, 0777);
19 REMOVE (file2); 44 REMOVE (file2);
20 } 45 }
21} 46}
22 47
48
23int 49int
24main (int argc, char **argv) 50main (int argc, char **argv)
25{ 51{
@@ -27,90 +53,71 @@ main (int argc, char **argv)
27 enum GNUNET_OS_ProcessStatusType status_type; 53 enum GNUNET_OS_ProcessStatusType status_type;
28 unsigned long code; 54 unsigned long code;
29 55
30/*
31if [ $# -ne 2 ]; then
32 exit 1
33fi
34*/
35 if (argc != 3) 56 if (argc != 3)
36 return 1; 57 return 1;
37 58
38/*
39rm -f $1 $2
40*/
41 removecerts (argv[1], argv[2]); 59 removecerts (argv[1], argv[2]);
42 /* Create RSA Private Key */ 60 /* Create RSA Private Key */
43/* 61 /* openssl genrsa -out $1 1024 2> /dev/null */
44openssl genrsa -out $1 1024 2> /dev/null 62 openssl = GNUNET_OS_start_process (NULL, NULL,
45*/ 63 "openssl",
46 openssl = GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "genrsa", "-out", argv[1], "1024", NULL); 64 "openssl",
47/* 65 "genrsa", "-out", argv[1], "1024",
48if [ $? -ne 0 ]; then 66 NULL);
49 rm -f $1 $2
50 exit 1
51fi
52*/
53 if (openssl == NULL) 67 if (openssl == NULL)
54 return 2; 68 return 2;
55 if (GNUNET_OS_process_wait (openssl) != GNUNET_OK) 69 if (GNUNET_OS_process_wait (openssl) != GNUNET_OK)
56 { 70 {
57 GNUNET_OS_process_kill (openssl, SIGTERM); 71 GNUNET_OS_process_kill (openssl, SIGTERM);
58 removecerts (argv[1], argv[2]); 72 removecerts (argv[1], argv[2]);
59 return 3; 73 return 3;
60 } 74 }
61 if (GNUNET_OS_process_status (openssl, &status_type, &code) != GNUNET_OK) 75 if (GNUNET_OS_process_status (openssl, &status_type, &code) != GNUNET_OK)
62 { 76 {
63 GNUNET_OS_process_kill (openssl, SIGTERM); 77 GNUNET_OS_process_kill (openssl, SIGTERM);
64 removecerts (argv[1], argv[2]); 78 removecerts (argv[1], argv[2]);
65 return 4; 79 return 4;
66 } 80 }
67 if (status_type != GNUNET_OS_PROCESS_EXITED || code != 0) 81 if (status_type != GNUNET_OS_PROCESS_EXITED || code != 0)
68 { 82 {
69 GNUNET_OS_process_kill (openssl, SIGTERM); 83 GNUNET_OS_process_kill (openssl, SIGTERM);
70 removecerts (argv[1], argv[2]); 84 removecerts (argv[1], argv[2]);
71 return 5; 85 return 5;
72 } 86 }
73 GNUNET_OS_process_close (openssl); 87 GNUNET_OS_process_close (openssl);
74 88
75 /* Create a self-signed certificate in batch mode using rsa key*/ 89 /* Create a self-signed certificate in batch mode using rsa key*/
76/* 90 /* openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null */
77 openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null 91 openssl = GNUNET_OS_start_process (NULL, NULL,
78*/ 92 "openssl",
79 openssl = GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "req", "-batch", "-days", "365", "-out", argv[2], "-new", "-x509", "-key", argv[1], NULL); 93 "openssl",
80/* 94 "req", "-batch", "-days", "365",
81if [ $? -ne 0 ]; then 95 "-out", argv[2], "-new", "-x509", "-key", argv[1],
82 rm -f $1 $2 96 NULL);
83 exit 1
84fi
85*/
86 if (openssl == NULL) 97 if (openssl == NULL)
87 return 6; 98 return 6;
88 if (GNUNET_OS_process_wait (openssl) != GNUNET_OK) 99 if (GNUNET_OS_process_wait (openssl) != GNUNET_OK)
89 { 100 {
90 GNUNET_OS_process_kill (openssl, SIGTERM); 101 GNUNET_OS_process_kill (openssl, SIGTERM);
91 removecerts (argv[1], argv[2]); 102 removecerts (argv[1], argv[2]);
92 return 7; 103 return 7;
93 } 104 }
94 if (GNUNET_OS_process_status (openssl, &status_type, &code) != GNUNET_OK) 105 if (GNUNET_OS_process_status (openssl, &status_type, &code) != GNUNET_OK)
95 { 106 {
96 GNUNET_OS_process_kill (openssl, SIGTERM); 107 GNUNET_OS_process_kill (openssl, SIGTERM);
97 removecerts (argv[1], argv[2]); 108 removecerts (argv[1], argv[2]);
98 return 8; 109 return 8;
99 } 110 }
100 if (status_type != GNUNET_OS_PROCESS_EXITED || code != 0) 111 if (status_type != GNUNET_OS_PROCESS_EXITED || code != 0)
101 { 112 {
102 GNUNET_OS_process_kill (openssl, SIGTERM); 113 GNUNET_OS_process_kill (openssl, SIGTERM);
103 removecerts (argv[1], argv[2]); 114 removecerts (argv[1], argv[2]);
104 return 9; 115 return 9;
105 } 116 }
106 GNUNET_OS_process_close (openssl); 117 GNUNET_OS_process_close (openssl);
107/*
108chmod 0400 $1 $2
109*/
110 CHMOD (argv[1], 0400); 118 CHMOD (argv[1], 0400);
111 CHMOD (argv[2], 0400); 119 CHMOD (argv[2], 0400);
112/*
113exit 0
114*/
115 return 0; 120 return 0;
116} 121}
122
123/* end of gnunet-transport-certificate-creation.c */