0 | 0 |
package POE::Component::SSLify;
|
1 | 1 |
|
2 | 2 |
# ABSTRACT: Makes using SSL in the world of POE easy!
|
|
3 |
|
|
4 |
BEGIN {
|
|
5 |
# should fix netbsd smoke failures, thanks BinGOs!
|
|
6 |
# <BinGOs> Apocal: okay cores with a 0.9.7d I've built myself from source. Doesn't if I comment out engine lines.
|
|
7 |
# BinGOs did an awesome job building various versions of openssl to try and track down the problem, it seems like
|
|
8 |
# newer versions of openssl worked fine on netbsd, but I don't want to do crazy stuff like probing openssl versions
|
|
9 |
# as it's fragile - best to let the user figure it out :)
|
|
10 |
#
|
|
11 |
# see http://www.cpantesters.org/cpan/report/1a660280-6eb1-11e0-a462-e9956c33433b
|
|
12 |
# http://www.cpantesters.org/cpan/report/49a9f2aa-6df2-11e0-a462-e9956c33433b
|
|
13 |
# http://www.cpantesters.org/cpan/report/78d9a234-6df5-11e0-a462-e9956c33433b
|
|
14 |
# and many other reports :(
|
|
15 |
#
|
|
16 |
#(gdb) bt
|
|
17 |
##0 0xbd9d3e7e in engine_table_select () from /usr/lib/libcrypto.so.2
|
|
18 |
##1 0xbd9b3bed in ENGINE_get_default_RSA () from /usr/lib/libcrypto.so.2
|
|
19 |
##2 0xbd9b1f6d in RSA_new_method () from /usr/lib/libcrypto.so.2
|
|
20 |
##3 0xbd9b1cf6 in RSA_new () from /usr/lib/libcrypto.so.2
|
|
21 |
##4 0xbd9cf8a1 in RSAPrivateKey_asn1_meth () from /usr/lib/libcrypto.so.2
|
|
22 |
##5 0xbd9da64b in ASN1_item_ex_new () from /usr/lib/libcrypto.so.2
|
|
23 |
##6 0xbd9da567 in ASN1_item_ex_new () from /usr/lib/libcrypto.so.2
|
|
24 |
##7 0xbd9d88cc in ASN1_item_ex_d2i () from /usr/lib/libcrypto.so.2
|
|
25 |
##8 0xbd9d8437 in ASN1_item_d2i () from /usr/lib/libcrypto.so.2
|
|
26 |
##9 0xbd9cf8d5 in d2i_RSAPrivateKey () from /usr/lib/libcrypto.so.2
|
|
27 |
##10 0xbd9ad546 in d2i_PrivateKey () from /usr/lib/libcrypto.so.2
|
|
28 |
##11 0xbd995e63 in PEM_read_bio_PrivateKey () from /usr/lib/libcrypto.so.2
|
|
29 |
##12 0xbd980430 in PEM_read_bio_RSAPrivateKey () from /usr/lib/libcrypto.so.2
|
|
30 |
##13 0xbda2e9dc in SSL_CTX_use_RSAPrivateKey_file () from /usr/lib/libssl.so.3
|
|
31 |
##14 0xbda5aabe in XS_Net__SSLeay_CTX_use_RSAPrivateKey_file (cv=0x8682c80)
|
|
32 |
# at SSLeay.c:1716
|
|
33 |
##15 0x08115401 in Perl_pp_entersub () at pp_hot.c:2885
|
|
34 |
##16 0x080e0ab7 in Perl_runops_debug () at dump.c:2049
|
|
35 |
##17 0x08078624 in S_run_body (oldscope=1) at perl.c:2308
|
|
36 |
##18 0x08077ef2 in perl_run (my_perl=0x823f030) at perl.c:2233
|
|
37 |
##19 0x0805e321 in main (argc=3, argv=0xbfbfe6a0, env=0xbfbfe6b0)
|
|
38 |
# at perlmain.c:117
|
|
39 |
##20 0x0805e0c6 in ___start ()
|
|
40 |
#(gdb)
|
|
41 |
if ( ! defined &LOAD_SSL_ENGINES ) { *LOAD_SSL_ENGINES = sub () { 0 } }
|
|
42 |
}
|
3 | 43 |
|
4 | 44 |
# We need Net::SSLeay or all's a failure!
|
5 | 45 |
BEGIN {
|
|
19 | 59 |
# Taken from http://search.cpan.org/~flora/Net-SSLeay-1.36/lib/Net/SSLeay.pm#Low_level_API
|
20 | 60 |
Net::SSLeay::load_error_strings();
|
21 | 61 |
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
22 | |
Net::SSLeay::ENGINE_load_builtin_engines();
|
23 | |
Net::SSLeay::ENGINE_register_all_complete();
|
|
62 |
if ( LOAD_SSL_ENGINES ) {
|
|
63 |
Net::SSLeay::ENGINE_load_builtin_engines();
|
|
64 |
Net::SSLeay::ENGINE_register_all_complete();
|
|
65 |
}
|
24 | 66 |
Net::SSLeay::randomize();
|
25 | 67 |
}
|
26 | 68 |
}
|
|
561 | 603 |
This module doesn't work on MSWin32 platforms at all ( XP, Vista, 7, etc ) because of some weird underlying fd issues. Since I'm not a windows
|
562 | 604 |
developer, I'm unable to fix this. However, it seems like Cygwin on MSWin32 works just fine! Please help me fix this if you can, thanks!
|
563 | 605 |
|
|
606 |
=head2 SSL ENGINEs
|
|
607 |
|
|
608 |
OpenSSL supports loading ENGINEs to accelerate the crypto algorithms. SSLify v1.004 automatically loaded the engines, but there was some
|
|
609 |
problems on certain platforms that caused coredumps. A big shout-out to BinGOs and CPANTesters for catching this! It's now disabled in v1.007
|
|
610 |
and you would need to explicitly enable it.
|
|
611 |
|
|
612 |
sub POE::Component::SSLify::LOAD_SSL_ENGINES () { 1 }
|
|
613 |
use POE::Component::SSLify qw( Client::SSLify );
|
|
614 |
|
564 | 615 |
=head1 EXPORT
|
565 | 616 |
|
566 | 617 |
Stuffs all of the functions in @EXPORT_OK so you have to request them directly.
|