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