Generate crt from csr

This commit is contained in:
Martin Lensment 2015-02-05 18:46:52 +02:00
parent 994d4140c2
commit bbe8a780a8
6 changed files with 58 additions and 7 deletions

View file

@ -28,7 +28,10 @@ class Admin::ApiUsersController < AdminController
def edit; end
def update
if @api_user.update(api_user_params)
app = api_user_params
app[:csr] = params[:api_user][:csr].open.read if params[:api_user][:csr]
if @api_user.update(app)
flash[:notice] = I18n.t('record_updated')
redirect_to [:admin, @api_user]
else
@ -47,6 +50,14 @@ class Admin::ApiUsersController < AdminController
end
end
def download_csr
send_data @api_user.csr, filename: "#{@api_user.username}.csr.pem"
end
def download_crt
send_data @api_user.crt, filename: "#{@api_user.username}.crt.pem"
end
private
def set_api_user
@ -54,6 +65,6 @@ class Admin::ApiUsersController < AdminController
end
def api_user_params
params.require(:api_user).permit(:username, :password, :crt, :active, :registrar_id, :registrar_typeahead)
params.require(:api_user).permit(:username, :password, :csr, :active, :registrar_id, :registrar_typeahead)
end
end