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