Class: WebPackage::Signer
- Inherits:
-
Object
- Object
- WebPackage::Signer
- Includes:
- Singleton, Helpers
- Defined in:
- lib/web_package/signer.rb
Overview
Performs signing of a message with ECDSA.
Instance Attribute Summary collapse
-
#cert ⇒ Object
readonly
Returns the value of attribute cert.
-
#cert_url ⇒ Object
readonly
Returns the value of attribute cert_url.
Class Method Summary collapse
Instance Method Summary collapse
- #cert_sha256 ⇒ Object
-
#initialize(path_to_cert, path_to_key) ⇒ Signer
constructor
A new instance of Signer.
- #sign(message) ⇒ Object
Constructor Details
#initialize(path_to_cert, path_to_key) ⇒ Signer
16 17 18 19 |
# File 'lib/web_package/signer.rb', line 16 def initialize(path_to_cert, path_to_key) @alg = OpenSSL::PKey::EC.new(File.read(path_to_key)) @cert = OpenSSL::X509::Certificate.new(File.read(path_to_cert)) end |
Instance Attribute Details
#cert ⇒ Object (readonly)
Returns the value of attribute cert.
10 11 12 |
# File 'lib/web_package/signer.rb', line 10 def cert @cert end |
#cert_url ⇒ Object (readonly)
Returns the value of attribute cert_url.
10 11 12 |
# File 'lib/web_package/signer.rb', line 10 def cert_url @cert_url end |
Class Method Details
.take ⇒ Object
12 13 14 |
# File 'lib/web_package/signer.rb', line 12 def self.take @@instance ||= new(Settings.cert_path, Settings.priv_path) end |
Instance Method Details
#cert_sha256 ⇒ Object
25 26 27 |
# File 'lib/web_package/signer.rb', line 25 def cert_sha256 @cert_sha256 ||= digest(@cert.to_der) end |
#sign(message) ⇒ Object
21 22 23 |
# File 'lib/web_package/signer.rb', line 21 def sign() @alg.dsa_sign_asn1 digest() end |