Answer the question
In order to leave comments, you need to log in
How to generate CMS PKCS file signature on Ruby on Rails?
Good afternoon, please tell me how to sign files, XML in Ruby on Rails Openssl
def create
@company = Company.find(params[:company_id])
@message = @company.messages.build(mess_params)
@message.uploads.select { |item|
item.sign_file = signFile(Paperclip.io_adapters.for(item.uploaded_file).read, request.session_options[:id].to_s)
}
@message.save
end
def signFile(data, id_session)
value = nil
keyname = 'keyp12'+id_session
p12 = OpenSSL::PKCS12.new( Rails.cache.fetch(keyname).p12_file)
value = OpenSSL::PKCS7::sign(p12.certificate, p12.key, data, [], OpenSSL::PKCS7::DETACHED)
end
return value.to_pem
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question