do some parsing of the incoming certificate
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sun, 10 Jan 2010 00:39:17 +0000 (19:39 -0500)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sun, 10 Jan 2010 00:39:17 +0000 (19:39 -0500)
msva

diff --git a/msva b/msva
index 785c061ce067efa9a6003ecb72afb58edf8790fb..09279bbb807b117804445951d4cb84b42ae894be 100755 (executable)
--- 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();