Index: preprover/XMLRPC.pm
===================================================================
--- preprover/XMLRPC.pm	(revision 19be89637c0443010ecbbadf110bda91fb5d8b1f)
+++ preprover/XMLRPC.pm	(revision 6159c8d128fb32d24e6602f4eb2c8f73eb239558)
@@ -30,6 +30,8 @@
 
 sub run {
-    my ($self, $port) = @_;
+    my ($self, $port, $cert, $key) = @_;
     croak "Must supply a port to run on" unless defined $port;
+    croak "Must give cert" unless defined $cert;
+    croak "Must give key" unless defined $key;
 
     my $srv = $$self;
@@ -38,4 +40,6 @@
         LocalPort   => $port,
         ReuseAddr   => 1,
+        SSL_key_file => $key,
+        SSL_certy_file => $cert,
         SSL_verify_mode => 3,
         SSL_ca_path => 'FAIL',  # if this isn't here, verify never gets called :D
Index: preprover/abac_preprover_client.pl
===================================================================
--- preprover/abac_preprover_client.pl	(revision 6159c8d128fb32d24e6602f4eb2c8f73eb239558)
+++ preprover/abac_preprover_client.pl	(revision 6159c8d128fb32d24e6602f4eb2c8f73eb239558)
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long;
+use Data::Dumper;
+use RPC::XML qw(smart_encode);
+use RPC::XML::ParserFactory;
+use LWP::UserAgent;
+use HTTP::Request;
+# use IO::Socket::SSL;
+
+use ABAC;
+
+use constant {
+    USER_AGENT  => 'abac/0.1.0',
+};
+
+my ($keystore, $cert, $key, $role);
+my $url = 'localhost:8000';
+GetOptions(
+    'keystore=s'    => \$keystore,
+    'url=s'         => \$url,
+    'cert=s'        => \$cert,
+    'key=s'         => \$key,
+    'role=s'        => \$role,
+) || usage();
+
+usage() unless defined $keystore && defined $cert && defined $key && defined $role;
+
+# code starts here
+ABAC::libabac_init;
+
+# load the certificates
+my $context = ABAC::Context->new;
+$context->load_directory($keystore);
+
+# build the XML RPC request
+my $request = RPC::XML::request->new(
+    'abac.query',
+    smart_encode({
+        role => $role,
+        credentials => [
+            map {{
+                attribute_cert  => RPC::XML::base64->new($_->attribute_cert),
+                issuer_cert     => RPC::XML::base64->new($_->issuer_cert),
+            }} @{$context->credentials}
+        ],
+    }),
+);
+
+# encode and send the HTTP POST
+my $request_body = $request->as_string;
+
+$ENV{HTTPS_CERT_FILE} = $cert;
+$ENV{HTTPS_KEY_FILE} = $key;
+$ENV{HTTPS_DEBUG} = 1;
+
+my $ua = LWP::UserAgent->new;
+
+my $request = HTTP::Request->new(
+    'POST',
+    "https://$url/RPC2",
+);
+$request->header('User-Agent', USER_AGENT);
+$request->header('Content-Length', length $request_body);
+$request->content($request_body);
+
+my $response = $ua->request($request);
+if (!$response->is_success) {
+    die $response->status_line;
+}
+
+# decode the reply
+my $xmlrpc_response = RPC::XML::ParserFactory->new->parse($response->decoded_content);
+print Dumper $xmlrpc_response;
+
+sub usage {
+    print "Usage: $0 \\\n";
+    print "        --keystore <keystore> [ --url <host:port> ] \\\n";
+    print "        --cert <cert.pem> --key <key.pem> \\\n";
+    print "        --role <keyid.role>\n";
+    print "    url defaults to localhost:8000\n";
+    exit 1;
+}
Index: preprover/abac_preprover_server.pl
===================================================================
--- preprover/abac_preprover_server.pl	(revision 6159c8d128fb32d24e6602f4eb2c8f73eb239558)
+++ preprover/abac_preprover_server.pl	(revision 6159c8d128fb32d24e6602f4eb2c8f73eb239558)
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long;
+use Data::Dumper;
+use IO::Socket::SSL qw(debug3);
+use XMLRPC;
+
+use lib '../swig/perl';
+use ABAC;
+
+ABAC::libabac_init;
+
+use constant {
+    PORT    => 8000,
+};
+
+my ($keystore, $cert, $key);
+my $port = 8000;
+GetOptions(
+    'keystore=s'    => \$keystore,
+    'port=i'        => \$port,
+    'cert=s'        => \$cert,
+    'key=s'        => \$key,
+) || usage();
+
+usage() unless defined $keystore && defined $cert && defined $key;
+
+my $ctx = ABAC::Context->new;
+$ctx->load_directory($keystore);
+
+my $server = XMLRPC->new();
+$server->add_method({
+    name        => 'abac.query',
+    code        => \&abac_query,
+    signature   => [ 'struct struct' ],
+});
+$server->run($port, $cert, $key);
+
+sub abac_query {
+    my ($server, $request) = @_;
+
+    my $peer_cert = $server->{peer_cert};
+    my $peer_id = ABAC::SSL_keyid($peer_cert);
+
+    # clone the context so the state remains pure between requests
+    my $local_ctx = ABAC::Context->new($ctx);
+    foreach my $cred (@{$request->{credentials}}) {
+        my $ret = $local_ctx->load_id_chunk($cred->{issuer_cert});
+        warn "Invalid issuer certificate" unless $ret == $ABAC::ABAC_CERT_SUCCESS;
+
+        $ret = $local_ctx->load_attribute_chunk($cred->{attribute_cert});
+        warn "Invalid attribute certificate" unless $ret == $ABAC::ABAC_CERT_SUCCESS;
+    }
+
+    my $role = $request->{role};
+    print "$role <- $peer_id\n";
+    my ($success, $credentials) = $local_ctx->query($role, $peer_id);
+
+    return $success;
+}
+
+sub usage {
+    print "Usage: $0 \\\n";
+    print "        --keystore <keystore> [ --port <port> ] \\\n";
+    print "        --cert <cert.pem> --key <key.pem>\n";
+    print "    port defaults to 8000\n";
+    exit 1;
+}
Index: preprover/client.pl
===================================================================
--- preprover/client.pl	(revision 19be89637c0443010ecbbadf110bda91fb5d8b1f)
+++ 	(revision )
@@ -1,63 +1,0 @@
-#!/usr/bin/perl
-
-use strict;
-use Data::Dumper;
-use RPC::XML qw(smart_encode);
-use RPC::XML::ParserFactory;
-use LWP::UserAgent;
-use HTTP::Request;
-# use IO::Socket::SSL;
-
-use lib '../swig/perl';
-use ABAC;
-ABAC::libabac_init;
-
-use constant {
-    USER_AGENT  => 'abac/0.1.0',
-};
-
-my ($keystore, $url) = @ARGV;
-die "Usage: $0 <keystore> <url>\n" unless defined $keystore && defined $url;
-
-# load the certificates
-my $context = ABAC::Context->new;
-$context->load_directory($keystore);
-
-# build the XML RPC request
-my $request = RPC::XML::request->new(
-    'abac.query',
-    smart_encode({
-        role => '06df985dc065fc69b508f6afa8dd127cd29ccc62.fed_create',
-        credentials => [
-            map {{
-                attribute_cert  => RPC::XML::base64->new($_->attribute_cert),
-                issuer_cert     => RPC::XML::base64->new($_->issuer_cert),
-            }} @{$context->credentials}
-        ],
-    }),
-);
-
-# encode and send the HTTP POST
-my $request_body = $request->as_string;
-
-$ENV{HTTPS_CERT_FILE} = 'certs/Jelena_ID.pem';
-$ENV{HTTPS_KEY_FILE} = 'certs/Jelena_private.pem';
-
-my $ua = LWP::UserAgent->new;
-
-my $request = HTTP::Request->new(
-    'POST',
-    "https://$url/RPC2",
-);
-$request->header('User-Agent', USER_AGENT);
-$request->header('Content-Length', length $request_body);
-$request->content($request_body);
-
-my $response = $ua->request($request);
-if (!$response->is_success) {
-    die $response->status_line;
-}
-
-# decode the reply
-my $xmlrpc_response = RPC::XML::ParserFactory->new->parse($response->decoded_content);
-print Dumper $xmlrpc_response;
Index: preprover/server.pl
===================================================================
--- preprover/server.pl	(revision 19be89637c0443010ecbbadf110bda91fb5d8b1f)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#!/usr/bin/perl
-
-use strict;
-use Data::Dumper;
-use XMLRPC;
-
-use lib '../swig/perl';
-use ABAC;
-
-ABAC::libabac_init;
-
-use constant {
-    PORT    => 8000,
-};
-
-my $keystore = shift || die "Usage: $0 <keystore>\n";
-my $ctx = ABAC::Context->new;
-$ctx->load_directory($keystore);
-
-my $server = XMLRPC->new();
-$server->add_method({
-    name        => 'abac.query',
-    code        => \&abac_query,
-    signature   => [ 'struct struct' ],
-});
-$server->run(8000);
-
-sub abac_query {
-    my ($server, $request) = @_;
-
-    my $peer_cert = $server->{peer_cert};
-    my $peer_id = ABAC::SSL_keyid($peer_cert);
-
-    # clone the context so the state remains pure between requests
-    my $local_ctx = ABAC::Context->new($ctx);
-    foreach my $cred (@{$request->{credentials}}) {
-        my $ret = $local_ctx->load_id_chunk($cred->{issuer_cert});
-        warn "Invalid issuer certificate" unless $ret == $ABAC::ABAC_CERT_SUCCESS;
-
-        $ret = $local_ctx->load_attribute_chunk($cred->{attribute_cert});
-        warn "Invalid attribute certificate" unless $ret == $ABAC::ABAC_CERT_SUCCESS;
-    }
-
-    my $role = $request->{role};
-    print "$role <- $peer_id\n";
-    my ($success, $credentials) = $local_ctx->query($role, $peer_id);
-
-    return $success;
-}
