Error with private/public keys openssl conf?

Error with private/public keys openssl conf?

santi macia
Vastuste arv 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 naeratus
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
Keskmine hinnang: -
Vastuses santi macia

Re: Error with private/public keys openssl conf?

Dan Marsden
Core developers pilt Particularly helpful Moodlers pilt Peer reviewers pilt Plugin developers pilt Plugins guardians pilt Testers pilt Translators pilt
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
Vastuses Dan Marsden

Re: Error with private/public keys openssl conf?

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;
Vastuses santi macia

Re: Error with private/public keys openssl conf?

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!
Vastuses santi macia

Re: Error with private/public keys openssl conf?

Dan Marsden
Core developers pilt Particularly helpful Moodlers pilt Peer reviewers pilt Plugin developers pilt Plugins guardians pilt Testers pilt Translators pilt
Vastuses Dan Marsden

Re: Error with private/public keys openssl conf?

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