From: skodak Date: Fri, 28 Nov 2008 12:54:15 +0000 (+0000) Subject: MDL-17419 misconfigured openssl extension blocks installation - openssl.cnf missing?? X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=eb7f89bc155da88cdd7895ff10bf2dae00e784f9;p=moodle.git MDL-17419 misconfigured openssl extension blocks installation - openssl.cnf missing?? --- diff --git a/mnet/environment.php b/mnet/environment.php index 88d2bc2bdc..8fc7ad47c6 100644 --- a/mnet/environment.php +++ b/mnet/environment.php @@ -152,8 +152,14 @@ class mnet_environment { function replace_keys() { global $DB, $CFG; + $keypair = mnet_generate_keypair(); + if (empty($keypair)) { + error_log('Can not generate keypair, sorry'); + return; + } + $this->keypair = array(); - $this->keypair = mnet_generate_keypair(); + $this->keypair = $keypair; $this->public_key = $this->keypair['certificate']; $details = openssl_x509_parse($this->public_key); $this->public_key_expires = $details['validTo_time_t']; diff --git a/mnet/lib.php b/mnet/lib.php index f6cc6ce5cd..39be23ed74 100644 --- a/mnet/lib.php +++ b/mnet/lib.php @@ -391,6 +391,10 @@ function mnet_generate_keypair($dn = null, $days=28) { $dn["commonName"] = preg_replace(':/$:', '', $dn["commonName"]); $new_key = openssl_pkey_new(); + if ($new_key === false) { + // can not generate keys - missing openssl.cnf?? + return null; + } $csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048)); $selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days); unset($csr_rsc); // Free up the resource