]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/gnutlscert.pm
Merge pull request #1162 from SaberUK/insp20+fix-deinstall
[user/henk/code/inspircd.git] / make / gnutlscert.pm
index 885a30603060fc038bc781fe7057466bd1d9ed5b..2c46e0e63e82b6eacb1e3beb1edc180ba38363b5 100644 (file)
@@ -1 +1,150 @@
-package make::gnutlscert;\r\ruse Exporter 'import';\ruse make::configure;\r@EXPORT = qw(make_gnutls_cert);\r\r\rsub make_gnutls_cert()\r{\r     open (FH, ">certtool.template");\r       my $timestr = time();\r  my $org = promptstring_s("Please enter the organization name", "My IRC Network");\r      my $unit = promptstring_s("Please enter the unit Name", "Server Admins");\r      my $state = promptstring_s("Pleae enter your state (two letter code)", "CA");\r  my $country = promptstring_s("Please enter your country", "Oompa Loompa Land");\r        my $commonname = promptstring_s("Please enter the certificate common name (hostname)", "irc.mynetwork.com");\r   my $email = promptstring_s("Please enter a contact email address", "oompa\@loompa.com");\r       print FH <<__END__;\r# X.509 Certificate options\r#\r# DN options\r\r# The organization of the subject.\rorganization = "$org"\r\r# The organizational unit of the subject.\runit = "$unit"\r\r# The locality of the subject.\r# locality =\r\r# The state of the certificate owner.\rstate = "$state"\r\r# The country of the subject. Two letter code.\rcountry = $country\r\r# The common name of the certificate owner.\rcn = "$commonname"\r\r# A user id of the certificate owner.\r#uid = "clauper"\r\r# If the supported DN OIDs are not adequate you can set\r# any OID here.\r# For example set the X.520 Title and the X.520 Pseudonym\r# by using OID and string pairs.\r#dn_oid = "2.5.4.12" "Dr." "2.5.4.65" "jackal"\r\r# This is deprecated and should not be used in new\r# certificates.\r# pkcs9_email = "none\@none.org"\r\r# The serial number of the certificate\rserial = $timestr\r\r# In how many days, counting from today, this certificate will expire.\rexpiration_days = 700\r\r# X.509 v3 extensions\r\r# A dnsname in case of a WWW server.\r#dns_name = "www.none.org"\r\r# An IP address in case of a server.\r#ip_address = "192.168.1.1"\r\r# An email in case of a person\remail = "$email"\r\r# An URL that has CRLs (certificate revocation lists)\r# available. Needed in CA certificates.\r#crl_dist_points = "http://www.getcrl.crl/getcrl/"\r\r# Whether this is a CA certificate or not\r#ca\r\r# Whether this certificate will be used for a TLS client\rtls_www_client\r\r# Whether this certificate will be used for a TLS server\rtls_www_server\r\r# Whether this certificate will be used to sign data (needed\r# in TLS DHE ciphersuites).\rsigning_key\r\r# Whether this certificate will be used to encrypt data (needed\r# in TLS RSA ciphersuites). Note that it is prefered to use different\r# keys for encryption and signing.\rencryption_key\r\r# Whether this key will be used to sign other certificates.\rcert_signing_key\r\r# Whether this key will be used to sign CRLs.\rcrl_signing_key\r\r# Whether this key will be used to sign code.\rcode_signing_key\r\r# Whether this key will be used to sign OCSP data.\rocsp_signing_key\r\r# Whether this key will be used for time stamping.\rtime_stamping_key\r__END__\rclose(FH);\rsystem("certtool --generate-privkey --outfile key.pem") or return 1;\rsystem("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem --template certtool.template") or return 1;\runlink("certtool.template");\r}\r\r1;\r\r
\ No newline at end of file
+#
+# InspIRCd -- Internet Relay Chat Daemon
+#
+#   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+#   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
+#
+# This file is part of InspIRCd.  InspIRCd is free software: you can
+# redistribute it and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+
+package make::gnutlscert;
+
+require 5.8.0;
+
+use strict;
+use warnings FATAL => qw(all);
+
+use Exporter 'import';
+use make::configure;
+our @EXPORT = qw(make_gnutls_cert);
+
+# On OS X the GnuTLS certtool is prefixed to avoid collision with the system certtool.
+my $certtool = $^O eq 'darwin' ? 'gnutls-certtool' : 'certtool';
+
+sub make_gnutls_cert()
+{
+       if (system "$certtool --version >/dev/null 2>&1")
+       {
+               print "\e[1;31mError:\e[0m unable to find '$certtool' in the PATH!\n";
+               return 1;
+       }
+       open (FH, ">certtool.template");
+       my $timestr = time();
+       my $commonname = promptstring_s('What is the hostname of your server?', 'irc.example.com');
+       my $email = promptstring_s('What email address can you be contacted at?', 'example@example.com');
+       my $unit = promptstring_s('What is the name of your unit?', 'Server Admins');
+       my $org = promptstring_s('What is the name of your organization?', 'Example IRC Network');
+       my $city = promptstring_s('What city are you located in?', 'Example City');
+       my $state = promptstring_s('What state are you located in?', 'Example State');
+       my $country = promptstring_s('What is the ISO 3166-1 code for the country you are located in?', 'XZ');
+       my $days = promptstring_s('How many days do you want your certificate to be valid for?', '365');
+       print FH <<__END__;
+# X.509 Certificate options
+#
+# DN options
+
+# The organization of the subject.
+organization = "$org"
+
+# The organizational unit of the subject.
+unit = "$unit"
+
+# The locality of the subject.
+locality = "$city"
+
+# The state of the certificate owner.
+state = "$state"
+
+# The country of the subject. Two letter code.
+country = "$country"
+
+# The common name of the certificate owner.
+cn = "$commonname"
+
+# A user id of the certificate owner.
+#uid = "clauper"
+
+# If the supported DN OIDs are not adequate you can set
+# any OID here.
+# For example set the X.520 Title and the X.520 Pseudonym
+# by using OID and string pairs.
+#dn_oid = "2.5.4.12" "Dr." "2.5.4.65" "jackal"
+
+# This is deprecated and should not be used in new
+# certificates.
+# pkcs9_email = "none\@none.org"
+
+# The serial number of the certificate
+serial = $timestr
+
+# In how many days, counting from today, this certificate will expire.
+expiration_days = $days
+
+# X.509 v3 extensions
+
+# A dnsname in case of a WWW server.
+#dns_name = "www.none.org"
+
+# An IP address in case of a server.
+#ip_address = "192.168.1.1"
+
+# An email in case of a person
+email = "$email"
+
+# An URL that has CRLs (certificate revocation lists)
+# available. Needed in CA certificates.
+#crl_dist_points = "http://www.getcrl.crl/getcrl/"
+
+# Whether this is a CA certificate or not
+#ca
+
+# Whether this certificate will be used for a TLS client
+tls_www_client
+
+# Whether this certificate will be used for a TLS server
+tls_www_server
+
+# Whether this certificate will be used to sign data (needed
+# in TLS DHE ciphersuites).
+signing_key
+
+# Whether this certificate will be used to encrypt data (needed
+# in TLS RSA ciphersuites). Note that it is prefered to use different
+# keys for encryption and signing.
+encryption_key
+
+# Whether this key will be used to sign other certificates.
+cert_signing_key
+
+# Whether this key will be used to sign CRLs.
+crl_signing_key
+
+# Whether this key will be used to sign code.
+code_signing_key
+
+# Whether this key will be used to sign OCSP data.
+ocsp_signing_key
+
+# Whether this key will be used for time stamping.
+time_stamping_key
+__END__
+close(FH);
+if ( (my $status = system("$certtool --generate-privkey --outfile key.pem")) ne 0) { return 1; }
+if ( (my $status = system("$certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem --template certtool.template")) ne 0) { return 1; }
+unlink("certtool.template");
+return 0;
+}
+
+1;
+