Skip Menu |
 

This queue is for tickets about the Net-SSLeay CPAN distribution.

Report information
The Basics
Id: 96820
Status: resolved
Priority: 0/
Queue: Net-SSLeay

People
Owner: MIKEM [...] cpan.org
Requestors: fraserbn [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.65



Subject: Android support
Download (untitled) / with headers
text/plain 1.8k
Howdy! Sicne Perl 5.20 now has Android support, I've been working on getting most of CPAN to work on the platform. For Net::SSLeay, this required two changes: lib/Net/SSLeay.pm: open_tcp_connection uses getprotobyname(), which Android doesn't have -- instead, it generates an "Unsupported socket function" exception at runtime. Thankfully, the fix is pretty simple; instead of using scalar-context getprotobyname('tcp'), you can instead look at the constant provided by Socket.pm: use Socket; my $proto = Socket::IPPROTO_TCP; SSLeay.xs: This one's a bit tougher. The libssl.so's that can be acquired for Android come without deprecated interfaces, which breaks the module since there is no RSA_generate_key() in the library. The non-trivial solution is to use RSA_generate_key_ex() instead; I managed to make it work (& have all of the tests pass) by tweaking the function so that it looks like this: RSA * RSA_generate_key(bits,ee,perl_cb=&PL_sv_undef,perl_data=&PL_sv_undef) int bits unsigned long ee SV* perl_cb SV* perl_data PREINIT: simple_cb_data_t* cb_data = NULL; CODE: int rc; RSA * ret; BIGNUM *e; e = BN_new(); BN_set_word(e, ee); cb_data = simple_cb_data_new(perl_cb, perl_data); BN_GENCB new_cb; BN_GENCB_set_old(&new_cb, ssleay_RSA_generate_key_cb_invoke, cb_data); ret = RSA_new(); rc = RSA_generate_key_ex(ret, bits, e, &new_cb); if (rc == -1 || ret == NULL) croak("Couldn't generate RSA key"); simple_cb_data_free(cb_data); BN_free(e); e = NULL; RETVAL = ret; OUTPUT: RETVAL ..but that will break for old openssl's, where the _ex function isn't available, so that should probably be wrapped in an #ifdef OPENSSL_VERSION_NUMBER >= (er, no clue 0.9.8 I think) or even an #ifdef __ANDROID__
Subject: Re: [rt.cpan.org #96820] Android support
Date: Tue, 01 Jul 2014 14:01:42 +1000
To: bug-Net-SSLeay [...] rt.cpan.org
From: Mike McCauley <mikem [...] airspayce.com>
Download (untitled) / with headers
text/plain 2.7k
Hi Brian, thanks for the patches. Now in SVN 417 and will be included in the next release. The RSA_generate_key code is under #ifdef __ANDROID__ I would be grateful if you would check that the SVN version is OK for you. Cheers. On Sunday, June 29, 2014 11:06:03 AM you wrote: Show quoted text
> Sun Jun 29 11:06:02 2014: Request 96820 was acted upon. > Transaction: Ticket created by Hugmeir > Queue: Net-SSLeay > Subject: Android support > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: fraserbn@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=96820 > > > > Howdy! > > Sicne Perl 5.20 now has Android support, I've been working on getting most > of CPAN to work on the platform. For Net::SSLeay, this required two > changes: > > lib/Net/SSLeay.pm: > open_tcp_connection uses getprotobyname(), which Android doesn't have -- > instead, it generates an "Unsupported socket function" exception at > runtime. Thankfully, the fix is pretty simple; instead of using > scalar-context getprotobyname('tcp'), you can instead look at the constant > provided by Socket.pm: > > use Socket; > my $proto = Socket::IPPROTO_TCP; > > SSLeay.xs: > This one's a bit tougher. The libssl.so's that can be acquired for Android > come without deprecated interfaces, which breaks the module since there is > no RSA_generate_key() in the library. The non-trivial solution is to use > RSA_generate_key_ex() instead; I managed to make it work (& have all of the > tests pass) by tweaking the function so that it looks like this: > > RSA * > RSA_generate_key(bits,ee,perl_cb=&PL_sv_undef,perl_data=&PL_sv_undef) > int bits > unsigned long ee > SV* perl_cb > SV* perl_data > PREINIT: > simple_cb_data_t* cb_data = NULL; > CODE: > int rc; > RSA * ret; > BIGNUM *e; > e = BN_new(); > BN_set_word(e, ee); > cb_data = simple_cb_data_new(perl_cb, perl_data); > BN_GENCB new_cb; > BN_GENCB_set_old(&new_cb, ssleay_RSA_generate_key_cb_invoke, > cb_data); > > ret = RSA_new(); > rc = RSA_generate_key_ex(ret, bits, e, &new_cb); > > if (rc == -1 || ret == NULL) > croak("Couldn't generate RSA key"); > simple_cb_data_free(cb_data); > BN_free(e); > e = NULL; > RETVAL = ret; > OUTPUT: > RETVAL > > ..but that will break for old openssl's, where the _ex function isn't > available, so that should probably be wrapped in an #ifdef > OPENSSL_VERSION_NUMBER >= (er, no clue 0.9.8 I think) or even an #ifdef > __ANDROID__
-- Mike McCauley VK4AMM mikem@airspayce.com Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.airspayce.com Phone +61 7 5598-7474
From: fraserbn [...] gmail.com
Download (untitled) / with headers
text/plain 419b
On Tue Jul 01 00:01:58 2014, mikem@airspayce.com wrote: Show quoted text
> Hi Brian, > > thanks for the patches. Now in SVN 417 and will be included in the > next > release. The RSA_generate_key code is under #ifdef __ANDROID__ > > I would be grateful if you would check that the SVN version is OK for > you. > > Cheers.
Oh damn, sorry, somehow rt never notified me of the reply. It builds, tests and install cleanly -- thank you!
Subject: Re: [rt.cpan.org #96820] Android support
Date: Sat, 26 Jul 2014 08:11:33 +1000
To: bug-Net-SSLeay [...] rt.cpan.org
From: Mike McCauley <mikem [...] airspayce.com>
Download (untitled) / with headers
text/plain 855b
Thanks, latest version 1.65 on CPAN now has these changes. Cheers. On Friday, July 25, 2014 06:00:32 PM you wrote: Show quoted text
> Queue: Net-SSLeay > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=96820 > > > On Tue Jul 01 00:01:58 2014, mikem@airspayce.com wrote:
> > Hi Brian, > > > > thanks for the patches. Now in SVN 417 and will be included in the > > next > > release. The RSA_generate_key code is under #ifdef __ANDROID__ > > > > I would be grateful if you would check that the SVN version is OK for > > you. > > > > Cheers.
> > Oh damn, sorry, somehow rt never notified me of the reply. It builds, tests > and install cleanly -- thank you!
-- Mike McCauley VK4AMM mikem@airspayce.com Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.airspayce.com Phone +61 7 5598-7474


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.