Error with private/public keys openssl conf?

Error with private/public keys openssl conf?

by santi macia -
Number of replies: 5
Hello

Im trying to connect two moodles in the same computer, with windows 2003 + xampp.


My first problem was generate public keys, so i replaced in /mnt/lib.php

$new_key = openssl_pkey_new();
$csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days);


$config = array(
"config" => "C:/Internet/xampp/apache/Apache2.2.9/conf/openssl.cnf"
);

$new_key = openssl_pkey_new($config);
$csr_rsc = openssl_csr_new($dn, $new_key, $config);
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days, $config);


And now i see the generated public key Mamatheka
But now when i click on services, i have this problem.

Warning: openssl_sign() [function.openssl-sign]: supplied key param cannot be coerced into a private key in C:\Internet\xampp\htdocs\claudigital\educacio\mnet\lib.php on line 172

Warning: openssl_open() [function.openssl-open]: unable to coerce parameter 4 into a private key in C:\Internet\xampp\htdocs\claudigital\educacio\mnet\xmlrpc\client.php on line 216

Warning: openssl_open() [function.openssl-open]: unable to coerce parameter 4 into a private key in C:\Internet\xampp\htdocs\claudigital\educacio\mnet\xmlrpc\client.php on line 229

Warning: openssl_open() [function.openssl-open]: unable to coerce parameter 4 into a private key in C:\Internet\xampp\htdocs\claudigital\educacio\mnet\xmlrpc\client.php on line 229

Warning: openssl_open() [function.openssl-open]: unable to coerce parameter 4 into a private key in C:\Internet\xampp\htdocs\claudigital\educacio\mnet\xmlrpc\client.php on line 229

I see the network faq and I set the openssl path on config.php

But nothing happens. What I can do?

thanx
Average of ratings: -
In reply to santi macia

Re: Error with private/public keys openssl conf?

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
you also need to make this change to the call to
openssl_pkey_export - as it requires a path to the openssl.cnf as well.

but - you'd be better upgrading your Moodle install as there's a fix in the latest version of 1.9Stable that allows you to set the path to openssl.cnf in your config.php file
In reply to Dan Marsden

Re: Error with private/public keys openssl conf?

by santi macia -
thanx, now I understand the error.

It's correct this modification? the generation of public key seems ok, but don't work services.



$config = array(
"config" => "C:/Internet/xampp/apache/bin/openssl.cnf"
);
$new_key = openssl_pkey_new($config);
$csr_rsc = openssl_csr_new($dn, $new_key, $config);
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days, $config);


unset($csr_rsc); // Free up the resource

// We export our self-signed certificate to a string.
openssl_x509_export($selfSignedCert, $keypair['certificate']);
openssl_x509_free($selfSignedCert);

// Export your public/private key pair as a PEM encoded string. You
// can protect it with an optional passphrase if you wish.
$export = openssl_pkey_export($new_key, $keypair['keypair_PEM'], null, $config /* , $passphrase */);
openssl_pkey_free($new_key);
unset($new_key); // Free up the resource

return $keypair;
In reply to santi macia

Re: Error with private/public keys openssl conf?

by santi macia -
Now, i've updated to 1.96 but I still have this error. I need to create digital certificate with openssl before? I've suppose that moodle do all...

correct me, thanx!
In reply to santi macia

Re: Error with private/public keys openssl conf?

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
have you set the path to your openssl.cnf file in your config.php?

see:
http://docs.moodle.org/en/Moodle_Network_FAQ#Moodle_doesn.27t_generate_any_keys_on_the_networking_pages
In reply to Dan Marsden

Re: Error with private/public keys openssl conf?

by santi macia -
yes, I see that before.

The solution was reconfiguring the moodle network again. And now everything runs well.

The step, redo the setup its very important :D