diff options
-rwxr-xr-x | configure | 8 | ||||
-rw-r--r-- | make/configure.pm | 14 | ||||
-rw-r--r-- | make/gnutlscert.pm | 114 |
3 files changed, 131 insertions, 5 deletions
@@ -24,6 +24,7 @@ use Getopt::Long; # Utility functions for our buildsystem use make::utilities; use make::configure; +use make::gnutlscert; GetOptions ( 'enable-gnutls' => \$opt_use_gnutls, @@ -703,11 +704,10 @@ if ($config{USE_GNUTLS} eq "y") { * Generating the Private Key may take some time, go grab a * * Coffee. Even better, to generate some more entropy if it * * is taking a while, open another console and type du / a * -* few times and get that HD going :) Then answer the * +* few times and get that HD going :) Then answer the * * Questions which follow. If you are unsure, just hit enter * *************************************************************\n\n"; - system("certtool --generate-privkey --outfile key.pem"); - system("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem"); + make_gnutls_cert(); print "\nCertificate generation complete, copying to config directory... "; system("mv key.pem $config{CONFIG_DIR}/key.pem"); system("mv cert.pem $config{CONFIG_DIR}/cert.pem"); @@ -742,7 +742,7 @@ if ($config{USE_GNUTLS} eq "y") { print "SSL Certificates Not found, Generating.. \n\n ************************************************************* * Generating the certificates may take some time, go grab a * -* coffee, or something. * +* coffee, or something. * *************************************************************\n\n"; system("openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem"); system("openssl dhparam -out dhparams.pem 1024"); diff --git a/make/configure.pm b/make/configure.pm index d151629f8..dd2dc9089 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -11,7 +11,7 @@ package make::configure; use Exporter 'import'; use POSIX; use make::utilities; -@EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies resolve_directory yesno showhelp); +@EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies resolve_directory yesno showhelp promptstring); my $no_svn = 0; @@ -148,6 +148,18 @@ sub promptnumeric($$) } } +sub promptstring($$) +{ + my ($prompt,$default) = @_; + my $var; + print "$prompt\n"; + print "[\033[1;32m$default\033[0m] -> "; + chomp($var = <STDIN>); + $var = $default if $var eq ""; + print "\n"; + return $var; +} + sub dumphash() { print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n"; diff --git a/make/gnutlscert.pm b/make/gnutlscert.pm new file mode 100644 index 000000000..d05f6f6a2 --- /dev/null +++ b/make/gnutlscert.pm @@ -0,0 +1,114 @@ +package make::gnutlscert; + +use Exporter 'import'; +use make::configure; +@EXPORT = qw(make_gnutls_cert); + + +sub make_gnutls_cert() +{ + open (FH, ">certtool.template"); + my $timestr = time(); + my $org = promptstring("Please enter the organization name", "My IRC Network"); + my $unit = promptstring("Please enter the unit Name", "Server Admins"); + my $state = promptstring("Pleae enter your state (two letter code)", "CA"); + my $country = promptstring("Please enter your country", "Oompa Loompa Land"); + my $commonname = promptstring("Please enter the certificate common name (hostname)", "irc.mynetwork.com"); + my $email = promptstring("Please enter a contact email address", "oompa\@loompa.com"); + 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 = + +# 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 = 700 + +# 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); +system("certtool --generate-privkey --outfile key.pem"); +system("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem --template certtool.template"); +unlink("certtool.template"); +} + +1; |