From: mike castleman Date: Sat, 9 Jan 2010 23:35:05 +0000 (-0500) Subject: msva.rb X-Git-Tag: msva-perl/0.1~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=14f3cf41009bb7ab2b9e5ab83623020935e5cf51;p=monkeysphere-validation-agent.git msva.rb --- diff --git a/msva.rb b/msva.rb new file mode 100644 index 0000000..ca4be59 --- /dev/null +++ b/msva.rb @@ -0,0 +1,41 @@ +#!/usr/bin/env ruby + +require 'rubygems' + +require 'json' +require 'openssl' +require 'sinatra' + +get '/' do + content_type 'text/plain; charset=us-ascii' + + "Hello from your friendly MSVA." +end + +post '/reviewcert' do + content_type "application/json" + + begin + params = JSON.parse(request.body.string) + rescue JSON::ParserError + halt({ :valid => false, :message => "couldn't parse JSON query"}) + end + + unless (params["pkc"] && params["pkc"]["type"] == "x509der") + halt({ :valid => false, :message => "pkc not present or of not-understood type" }.to_json) + end + + data = params["pkc"]["data"].pack("C*") + pkey = OpenSSL::X509::Certificate.new(data).public_key + + { :valid => false, :message => "Just testing!!" }.to_json +end + +get '/noop' do + { :available => true, :protoversion => 1, :server => "MSVA-Ruby 0.00001" }.to_json +end + +post '/extracerts' do + # TODO: fill in if we need to do so + not_found +end