2 # InspIRCd -- Internet Relay Chat Daemon
4 # Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 # Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
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.
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
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/>.
21 package make::gnutlscert;
26 use warnings FATAL => qw(all);
28 use Exporter 'import';
30 our @EXPORT = qw(make_gnutls_cert);
33 sub make_gnutls_cert()
35 open (FH, ">certtool.template");
37 my $commonname = promptstring_s('What is the hostname of your server?', 'irc.example.com');
38 my $email = promptstring_s('What email address can you be contacted at?', 'example@example.com');
39 my $unit = promptstring_s('What is the name of your unit?', 'Server Admins');
40 my $org = promptstring_s('What is the name of your organization?', 'Example IRC Network');
41 my $city = promptstring_s('What city are you located in?', 'Example City');
42 my $state = promptstring_s('What state are you located in?', 'Example State');
43 my $country = promptstring_s('What is the ISO 3166-1 code for the country you are located in?', 'XZ');
44 my $days = promptstring_s('How many days do you want your certificate to be valid for?', '365');
46 # X.509 Certificate options
50 # The organization of the subject.
53 # The organizational unit of the subject.
56 # The locality of the subject.
59 # The state of the certificate owner.
62 # The country of the subject. Two letter code.
65 # The common name of the certificate owner.
68 # A user id of the certificate owner.
71 # If the supported DN OIDs are not adequate you can set
73 # For example set the X.520 Title and the X.520 Pseudonym
74 # by using OID and string pairs.
75 #dn_oid = "2.5.4.12" "Dr." "2.5.4.65" "jackal"
77 # This is deprecated and should not be used in new
79 # pkcs9_email = "none\@none.org"
81 # The serial number of the certificate
84 # In how many days, counting from today, this certificate will expire.
85 expiration_days = $days
89 # A dnsname in case of a WWW server.
90 #dns_name = "www.none.org"
92 # An IP address in case of a server.
93 #ip_address = "192.168.1.1"
95 # An email in case of a person
98 # An URL that has CRLs (certificate revocation lists)
99 # available. Needed in CA certificates.
100 #crl_dist_points = "http://www.getcrl.crl/getcrl/"
102 # Whether this is a CA certificate or not
105 # Whether this certificate will be used for a TLS client
108 # Whether this certificate will be used for a TLS server
111 # Whether this certificate will be used to sign data (needed
112 # in TLS DHE ciphersuites).
115 # Whether this certificate will be used to encrypt data (needed
116 # in TLS RSA ciphersuites). Note that it is prefered to use different
117 # keys for encryption and signing.
120 # Whether this key will be used to sign other certificates.
123 # Whether this key will be used to sign CRLs.
126 # Whether this key will be used to sign code.
129 # Whether this key will be used to sign OCSP data.
132 # Whether this key will be used for time stamping.
136 my $certtool = "certtool";
137 if (`uname -s` eq "Darwin\n") {
138 # On OS X the certtool binary name is different to prevent
139 # collisions with the system certtool from NSS.
140 $certtool = "gnutls-certtool";
142 if ( (my $status = system("$certtool --generate-privkey --outfile key.pem")) ne 0) { return 1; }
143 if ( (my $status = system("$certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem --template certtool.template")) ne 0) { return 1; }
144 unlink("certtool.template");