D
D
dexdev2017-05-28 18:19:54
OpenSSL
dexdev, 2017-05-28 18:19:54

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

returns a certificate, I don’t understand what to do with it, how to make a CMS or PKCS # 7 signature?
certificate revocation checks go through other actions
Legally valid signature and OCSP timestamp required

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question