Skip to content
Browse files

let users get their certs

  • Loading branch information...
1 parent 557884a commit bd94289795ad0efbe81977eb4a881c1fffecfb56 @labria committed Feb 25, 2008
Showing with 12 additions and 3 deletions.
  1. +10 −1 app/controllers/users_controller.rb
  2. +2 −2 config/routes.rb
View
11 app/controllers/users_controller.rb
@@ -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
View
4 config/routes.rb
@@ -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.

0 comments on commit bd94289

Please sign in to comment.
Something went wrong with that request. Please try again.