Monks, I supplicate myself before the collective wisdom of the monastery. I have recently been playing around with the JSON::RPC::Server::Daemon module. I have had some luck implementing it w/o SSL but I would like to utilize SSL going forward. I am currently testing on a self-signed certificate via this guide. I set up httpd to use the certificate and it's working as designed (albeit with the unsigned cert warning...). Here is my constructor for the the JSON Daemon:
my $ssl_key_path = '/etc/pki/tls/private/ca.key'; my $ssl_cert_path = '/etc/pki/tls/cert.pem'; my $port = $ARGV[0]; $port = 88888 unless $port; my $server = JSON::RPC::Server::Daemon->new( LocalAddr => '127.0.0.1', LocalPort => $port, SSL_key_file => $ssl_key_path, SSL_cert_file => $ssl_cert_path, SSL_verify_mode => 0 ) || die "failed to listen: $!"; $server->dispatch({'/test' => 'myApp'}); $server->handle();
This code runs w/o error, however, as soon as I try to connect via a simple client the daemon quits (again w/o error -- though I'm unsure where to trap an error w/o overloading the module). Here is the client script:
#!/usr/bin/perl use JSON::RPC::Client; my $client = new JSON::RPC::Client; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; my $port = $ARGV[0]; $port = 88888 unless $port; my $uri = 'https://127.0.0.1:'.$port.'/test'; my $obj = { method => 'get_ticket_info', # or 'MyApp.sum' params => [105195,555435], }; my $res = $client->call( $uri, $obj );
Prior to trying to implement SSL I was having no problems sending requests and responding to them. I based my SSL cert lines in the Daemon constructor on the IO::Socket:SSL documentation. Has anyone been able to get SSL to work with the JSON::RPC::Server::Daemon module? I've noticed there is not much documentation or example code on the web which leads me to think people might be using other alternatives for this type of job. Thanks for your time!

In reply to JSON::RPC::Server with SSL by mwb613

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.