add signature verification

This commit is contained in:
Alex Turchyn
2023-06-24 12:27:34 +03:00
parent 0ac30a5fc0
commit c9e255f589
19 changed files with 231 additions and 61 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ module GenerateCertificate
key = OpenSSL::PKey::RSA.new(SIZE)
cert = OpenSSL::X509::Certificate.new
cert.subject = OpenSSL::X509::Name.parse("/C=AT/O=#{name}/CN=#{name} Certificate")
cert.subject = OpenSSL::X509::Name.parse("/C=AT/O=#{name}/CN=#{name}")
cert.issuer = ca_cert.subject
cert.not_before = Time.current
cert.not_after = 100.years.from_now
@@ -5,6 +5,8 @@ module Submissions
FONT_SIZE = 11
FONT_NAME = 'Helvetica'
INFO_CREATOR = 'DocuSeal (https://www.docuseal.co)'
A4_SIZE = [595, 842].freeze
module_function
@@ -165,7 +167,9 @@ module Submissions
def save_signed_pdf(pdf:, submitter:, cert:, uuid:, name:)
io = StringIO.new
pdf.sign(io, reason: "Signed by #{submitter.email}",
pdf.trailer[:Info][:Creator] = INFO_CREATOR
pdf.sign(io, reason: "Signed by #{submitter.email} with docuseal.co",
certificate: OpenSSL::X509::Certificate.new(cert['cert']),
key: OpenSSL::PKey::RSA.new(cert['key']),
certificate_chain: [OpenSSL::X509::Certificate.new(cert['sub_ca']),