Module: BaUpload
- Defined in:
- lib/ba_upload.rb,
lib/ba_upload/version.rb,
lib/ba_upload/connection.rb,
lib/ba_upload/error_file.rb,
lib/ba_upload/statistic_file.rb
Defined Under Namespace
Classes: Connection, ErrorFile, StatisticFile
Constant Summary
collapse
- VERSION =
"0.5.0"
Class Method Summary
collapse
Class Method Details
.export_certificate(file_path:, passphrase:) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/ba_upload.rb', line 10
def self.export_certificate(file_path:, passphrase:)
cert = OpenSSL::PKCS12.new(File.read(file_path), passphrase)
{
key: Tempfile.new(['key','.pem']).tap{|f| f.write(cert.key.to_s); f.flush},
cert: Tempfile.new(['cert','.pem']).tap{|f| f.write(cert.certificate.to_s); f.flush},
ca_cert: Tempfile.new(['ca_cert','.pem']).tap{|f| f.write(cert.ca_certs.reverse.join("\n")); f.flush }
}
end
|
.open(file_path:, passphrase:, &block) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/ba_upload.rb', line 24
def self.open(file_path:, passphrase:, &block)
conn = BaUpload.open_connection(file_path: file_path, passphrase: passphrase)
block.call(conn)
ensure
conn.shutdown
end
|
.open_connection(file_path:, passphrase:) ⇒ Object
19
20
21
22
|
# File 'lib/ba_upload.rb', line 19
def self.open_connection(file_path:, passphrase:)
cert = BaUpload.export_certificate(file_path: file_path, passphrase: passphrase)
BaUpload::Connection.new(cert[:key], cert[:cert], cert[:ca_cert])
end
|