From 9ca7b32701e3cd27c469d01a097f416fd214975f Mon Sep 17 00:00:00 2001 From: mike castleman Date: Tue, 12 Jan 2010 00:11:40 -0500 Subject: [PATCH] first working version of msva-rb --- msva.rb | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100755 msva.rb diff --git a/msva.rb b/msva.rb deleted file mode 100755 index 3d97ba7..0000000 --- a/msva.rb +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env ruby - -require 'rubygems' - -require 'json' -require 'openssl' -require 'sinatra' - -configure do - git_dir = File.join(File.dirname(__FILE__), ".git") - if File.directory?(git_dir) - head = File.read("#{git_dir}/HEAD").strip.split[-1] - @@git_rev = File.read(File.join(git_dir, head)).strip - end -end - -get '/' do - content_type "application/json" - - result = { :available => true, :protoversion => 1, :server => "MSVA-Ruby 0.00001" } - result[:git_revision] = @@git_rev if @@git_rev - result.to_json -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"}.to_json) - 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 - -# TODO: fill in if we need to do so -# post '/extracerts' do -# end - -not_found do - content_type "application/json" - - { :status => 404, :message => "not found" }.to_json -end -- 2.26.2