From: Daniel Kahn Gillmor Date: Sun, 10 Jan 2010 00:39:17 +0000 (-0500) Subject: do some parsing of the incoming certificate X-Git-Tag: msva-perl/0.1~32^2~2^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=81f28e7f4c5c7b8b4dee46c39a13cc2628e167ea;p=monkeysphere-validation-agent.git do some parsing of the incoming certificate --- diff --git a/msva b/msva index 785c061..09279bb 100755 --- a/msva +++ b/msva @@ -10,6 +10,8 @@ use strict; use base qw(HTTP::Server::Simple::CGI); use warnings; use strict; + use Crypt::GPG; + use Crypt::X509; use JSON; @@ -18,6 +20,18 @@ use strict; '/extracerts' => \&extracerts, ); + + sub new { + my $class = shift; + # start the server on port 8901 + my $self = $class->SUPER::new(8901); + + $self->{_gpg} = new Crypt::GPG; + + bless ($self, $class); + return $self; + } + sub handle_request { my $self = shift; my $cgi = shift; @@ -47,10 +61,14 @@ use strict; my $data = from_json($cgi->param('POSTDATA')); use Data::Dumper; - print STDERR Dumper($data); - my $uid = $data->{context}.'://'.$data->{uid}; + my $cert = Crypt::X509->new(cert => join('', map(chr, @{$data->{pkc}->{data}}))); + + printf STDERR "cert subject was: %s\n", $cert->subject_cn(); + printf STDERR "cert issuer was: %s\n", $cert->issuer_cn(); + + my $ret = { valid => JSON::true, message => sprintf('tried to validate "%s" through the OpenPGP Web of Trust', $uid) }; my $status = '200 match found, authentication details to follow'; @@ -65,6 +83,5 @@ use strict; } } -# start the server on port 8091 -my $server = MSVA->new(8901); +my $server = MSVA->new(); $server->run();