From 76cacb1adf0c7572ceae85600a217f9f294d042a Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 18 Oct 2010 00:18:16 -0400 Subject: [PATCH] hand pkc data over to Client.pm as a variable, instead of letting Client.pm read it from stdin directly --- Crypt/Monkeysphere/MSVA/Client.pm | 39 +++++++++++-------------------- msva-query-agent | 9 ++++++- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Crypt/Monkeysphere/MSVA/Client.pm b/Crypt/Monkeysphere/MSVA/Client.pm index dc4532f..2939ca0 100644 --- a/Crypt/Monkeysphere/MSVA/Client.pm +++ b/Crypt/Monkeysphere/MSVA/Client.pm @@ -45,15 +45,16 @@ my $context = shift; my $peer = shift; my $pkctype = shift; + my $pkcdata = shift; - my $apd = create_apd($context, $peer, $pkctype); + my $apd = create_apd($context, $peer, $pkctype, $pkcdata); my $apdjson = to_json($apd); # get msva socket from environment my $msvasocket = $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET}; - # creat the user agent + # create the user agent my $ua = LWP::UserAgent->new; my $headers = HTTP::Headers->new( @@ -84,15 +85,7 @@ my $context = shift; my $peer = shift; my $pkctype = shift; - - my $pkcdata; - my $pkcdataraw; - - # load raw pkc data from stdin - $pkcdataraw = do { - local $/; # slurp! - ; - }; + my $pkcdata = shift; msvalog('debug', "context: %s\n", $context); msvalog('debug', "peer: %s\n", $peer); @@ -100,7 +93,7 @@ if ($pkctype eq 'x509der') { - my $cert = Crypt::X509->new(cert => $pkcdataraw); + my $cert = Crypt::X509->new(cert => $pkcdata); if ($cert->error) { die; }; @@ -114,19 +107,15 @@ die; }; - # remap raw pkc data into numeric array - my @remap = map(ord, split(//,$pkcdataraw)); - - my %apd = ( - context => $context, - peer => $peer, - pkc => { - type => $pkctype, - data => \@remap, - }, - ); - - return \%apd; + return { + context => $context, + peer => $peer, + pkc => { + type => $pkctype, + # remap raw pkc data into numeric array + data => [map(ord, split(//,$pkcdata))], + }, + }; } 1; diff --git a/msva-query-agent b/msva-query-agent index ea1f7f2..8dfd192 100755 --- a/msva-query-agent +++ b/msva-query-agent @@ -25,7 +25,14 @@ use Crypt::Monkeysphere::MSVA::Client; my $context = shift; my $peer = shift; my $pkctype = shift || 'x509der'; -my ($status,$ret) = Crypt::Monkeysphere::MSVA::Client->query_agent($context,$peer,$pkctype); + +# load raw pkc data from stdin +my $pkcdata = do { + local $/; # slurp! + ; +}; + +my ($status,$ret) = Crypt::Monkeysphere::MSVA::Client->query_agent($context,$peer,$pkctype, $pkcdata); msvalog('info', "status: %s\n", $status); msvalog('info', "valid: %s\n", $ret->{valid}); -- 2.26.2