]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/gnutlscert.pm
ab8aae4279d1a4d45f251736bff6d5de34510800
[user/henk/code/inspircd.git] / make / gnutlscert.pm
1 #
2 # InspIRCd -- Internet Relay Chat Daemon
3 #
4 #   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 #   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
6 #
7 # This file is part of InspIRCd.  InspIRCd is free software: you can
8 # redistribute it and/or modify it under the terms of the GNU General Public
9 # License as published by the Free Software Foundation, version 2.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20
21 package make::gnutlscert;
22
23 require 5.8.0;
24
25 use strict;
26 use warnings FATAL => qw(all);
27
28 use Exporter 'import';
29 use make::configure;
30 our @EXPORT = qw(make_gnutls_cert);
31
32
33 sub make_gnutls_cert()
34 {
35         open (FH, ">certtool.template");
36         my $timestr = time();
37         my $org = promptstring_s("Please enter the organization name", "My IRC Network");
38         my $unit = promptstring_s("Please enter the unit Name", "Server Admins");
39         my $state = promptstring_s("Please enter your state (two letter code)", "CA");
40         my $country = promptstring_s("Please enter your country", "Oompa Loompa Land");
41         my $commonname = promptstring_s("Please enter the certificate common name (hostname)", "irc.mynetwork.com");
42         my $email = promptstring_s("Please enter a contact email address", "oompa\@loompa.com");
43         print FH <<__END__;
44 # X.509 Certificate options
45 #
46 # DN options
47
48 # The organization of the subject.
49 organization = "$org"
50
51 # The organizational unit of the subject.
52 unit = "$unit"
53
54 # The locality of the subject.
55 # locality =
56
57 # The state of the certificate owner.
58 state = "$state"
59
60 # The country of the subject. Two letter code.
61 country = $country
62
63 # The common name of the certificate owner.
64 cn = "$commonname"
65
66 # A user id of the certificate owner.
67 #uid = "clauper"
68
69 # If the supported DN OIDs are not adequate you can set
70 # any OID here.
71 # For example set the X.520 Title and the X.520 Pseudonym
72 # by using OID and string pairs.
73 #dn_oid = "2.5.4.12" "Dr." "2.5.4.65" "jackal"
74
75 # This is deprecated and should not be used in new
76 # certificates.
77 # pkcs9_email = "none\@none.org"
78
79 # The serial number of the certificate
80 serial = $timestr
81
82 # In how many days, counting from today, this certificate will expire.
83 expiration_days = 700
84
85 # X.509 v3 extensions
86
87 # A dnsname in case of a WWW server.
88 #dns_name = "www.none.org"
89
90 # An IP address in case of a server.
91 #ip_address = "192.168.1.1"
92
93 # An email in case of a person
94 email = "$email"
95
96 # An URL that has CRLs (certificate revocation lists)
97 # available. Needed in CA certificates.
98 #crl_dist_points = "http://www.getcrl.crl/getcrl/"
99
100 # Whether this is a CA certificate or not
101 #ca
102
103 # Whether this certificate will be used for a TLS client
104 tls_www_client
105
106 # Whether this certificate will be used for a TLS server
107 tls_www_server
108
109 # Whether this certificate will be used to sign data (needed
110 # in TLS DHE ciphersuites).
111 signing_key
112
113 # Whether this certificate will be used to encrypt data (needed
114 # in TLS RSA ciphersuites). Note that it is prefered to use different
115 # keys for encryption and signing.
116 encryption_key
117
118 # Whether this key will be used to sign other certificates.
119 cert_signing_key
120
121 # Whether this key will be used to sign CRLs.
122 crl_signing_key
123
124 # Whether this key will be used to sign code.
125 code_signing_key
126
127 # Whether this key will be used to sign OCSP data.
128 ocsp_signing_key
129
130 # Whether this key will be used for time stamping.
131 time_stamping_key
132 __END__
133 close(FH);
134 if ( (my $status = system("certtool --generate-privkey --outfile key.pem")) ne 0) { return 1; }
135 if ( (my $status = system("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem --template certtool.template")) ne 0) { return 1; }
136 unlink("certtool.template");
137 return 0;
138 }
139
140 1;
141