mwb613 has asked for the wisdom of the Perl Monks concerning the following question:
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:
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: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();
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!#!/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 );
Back to
Seekers of Perl Wisdom