Skip to content

Commit

Permalink
let users get their certs
Browse files Browse the repository at this point in the history
  • Loading branch information
labria committed Feb 25, 2008
1 parent 557884a commit bd94289
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ def create
render :action => 'new'
end
end

def get_cert
unless logged_in?
redirect_back_or_default('/')
else
pkey = OpenSSL::PKey::RSA.new(File. read("cert/#{current_user.login}/#{current_user.login}_keypair.pem"))
cert = OpenSSL::X509::Certificate.new(File.read("cert/#{current_user.login}/cert_#{current_user.login}.pem"))
p12 = OpenSSL::PKCS12.create(nil, "#{current_user.login} cert", pkey, cert)
send_data p12.to_der, :type => 'application/x-pkcs12', :filename => "#{current_user.login}.p12"
end
end
end
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ActionController::Routing::Routes.draw do |map|
map.resources :users


map.resources :users, :collection => { :get_cert => :get }
map.resource :session

# The priority is based upon order of creation: first created -> highest priority.
Expand Down

0 comments on commit bd94289

Please sign in to comment.