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 $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("Pleae 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");
44 # X.509 Certificate options
48 # The organization of the subject.
51 # The organizational unit of the subject.
54 # The locality of the subject.
57 # The state of the certificate owner.
60 # The country of the subject. Two letter code.
63 # The common name of the certificate owner.
66 # A user id of the certificate owner.
69 # If the supported DN OIDs are not adequate you can set
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"
75 # This is deprecated and should not be used in new
77 # pkcs9_email = "none\@none.org"
79 # The serial number of the certificate
82 # In how many days, counting from today, this certificate will expire.
87 # A dnsname in case of a WWW server.
88 #dns_name = "www.none.org"
90 # An IP address in case of a server.
91 #ip_address = "192.168.1.1"
93 # An email in case of a person
96 # An URL that has CRLs (certificate revocation lists)
97 # available. Needed in CA certificates.
98 #crl_dist_points = "http://www.getcrl.crl/getcrl/"
100 # Whether this is a CA certificate or not
103 # Whether this certificate will be used for a TLS client
106 # Whether this certificate will be used for a TLS server
109 # Whether this certificate will be used to sign data (needed
110 # in TLS DHE ciphersuites).
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.
118 # Whether this key will be used to sign other certificates.
121 # Whether this key will be used to sign CRLs.
124 # Whether this key will be used to sign code.
127 # Whether this key will be used to sign OCSP data.
130 # Whether this key will be used for time stamping.
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");