Sha256: fde2c398081b2922996167fdcecadccccde4a15ada3e12f6b5bdce5422fb59b5

Contents?: true

Size: 406 Bytes

Versions: 4

Compression:

Stored size: 406 Bytes

Contents

require 'openssl'

module Smartdc
  module Auth
    def self.sign(request={}, options={})
      rsa = OpenSSL::PKey::RSA.new File.read options[:rsa_path]
      sha256 = OpenSSL::Digest::SHA256.new
      raw = [rsa.sign(sha256, request[:headers][:date])].pack('m').delete("\r\n")
      "Signature keyId=\"/#{options[:username]}/keys/#{options[:use_key]}\",algorithm=\"rsa-sha256\" #{raw}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smartdc-1.3.0 lib/smartdc/auth.rb
smartdc-1.2.2 lib/smartdc/auth.rb
smartdc-1.2.1 lib/smartdc/auth.rb
smartdc-1.1.1 lib/smartdc/auth.rb