Internal server error when creating keys for RSA

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

Internal server error when creating keys for RSA

Postby tchule » Mon Aug 19, 2013 2:10 pm

Hello,

I have a "Internal server error" when creating the keys on my computer.

I'm trying to test the generation of RSA keys with PHPSecLib version 0.3.5, and I have a server error with no log on my config.

The error is located between the lines 1650 and 1685 of the "BigInteger.php" file. When I comment the 'MATH_BIGINTEGER_OPENSSL_ENABLED' clause, the key generation works OK.

I'm using PHP 5.3.4 on windows.

PHPInfo :

Build Date May 14 2012 15:14:00
Compiler MSVC9 (Visual C++ 2008)
Architecture x86
Configure Command cscript /nologo configure.js "--enable-cli" "--with-pgsql" "--with-curl" "--with-openssl" "--with-mysql" "--with-mysqli" "--enable-pdo" "--with-pdo-pgsql" "--with-pdo-odbc" "--with-pdo-sqlite" "--with-sqlite3" "--enable-dbase" "--with-gettext=D:\build\mapserver-buildkit-2008\gettext-runtime-0.17-source\MSVC9\libintl_static\Release" "--enable-mbstring" "--enable-mbregex" "--without-t1lib" "--enable-soap" "--with-mcrypt" "--enable-exif" "--with-ldap"
Server API CGI/FastCGI
openssl

OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.1c 10 May 2012
OpenSSL Header Version OpenSSL 0.9.8u 12 Mar 2012


I haven't located more precisely where the error is coming from. Since I haven't found any log I need to go step by step.

Best Regards,
tchule
Traveler
 
Posts: 3
Joined: Mon Aug 19, 2013 2:01 pm

Re: Internal server error when creating keys for RSA

Postby TerraFrost » Mon Aug 19, 2013 6:26 pm

The way I generally pinpoint issues like that is by adding exit('this far') statements at random places. eg. Maybe I'll add it to the constructor of Crypt_RSA and if that works I'll move that exit() to createKey and so on and so forth until 'this far' stops appearing. That'll tell me where the error is occurring.

If you could give me server access I could do this myself..
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Internal server error when creating keys for RSA

Postby tchule » Mon Aug 19, 2013 6:39 pm

I've done the same, added logs at various places. I will try to go further tomorrow, I'll keep you informed.
tchule
Traveler
 
Posts: 3
Joined: Mon Aug 19, 2013 2:01 pm

Re: Internal server error when creating keys for RSA

Postby tchule » Tue Aug 20, 2013 6:34 am

OK, solved (in my case)

The problem seemed to be with the "openssl_public_encrypt" function.

The error occurs in this line :
if (openssl_public_encrypt($plaintext, $result, $RSAPublicKey, OPENSSL_NO_PADDING)) {

The only log I have in Apche is this :
[Tue Aug 20 08:17:29 2013] [error] [client 127.0.0.1] Premature end of script headers: php-cgi.exe,

I have tried something in the lines of what is proposed in this forum :
http://stackoverflow.com/questions/8423 ... tion-reset

I use MS4W and I have copied the libeay32.dll and ssleay32.dll files from the Apache/bin directory to the Apache/cgi-bin directory.

After restart :
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8t 18 Jan 2012
OpenSSL Header Version OpenSSL 0.9.8u 12 Mar 2012

And now it works.

I still have to find a javascript RSA library that works with the PHP part but it's another matter.

Thanks,
tchule
Traveler
 
Posts: 3
Joined: Mon Aug 19, 2013 2:01 pm


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest

cron