Forum: Ruby Ruby script - unable to load "ecdsa" file

Fd7788760fdcf0cb511f15544f288356?d=identicon&s=25 Priy Nag (newruby901)
on 2014-04-18 22:57
I am new to Ruby and have a .rb script to run.  I've downloaded
"Ruby200" and when I try to run the script I get some errors as below.
What does it mean?  It says ecdsa (Load Error), is this a file that user
needs to supply?  Our team doesn't own it but we got a request to run
this script, so i'm investigating.  Please help m.e

C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
`require
': cannot load such file -- ecdsa (LoadError)
        from
C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:5
5:in `require'
        from xasstest.rb:9:in `<main>'
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-04-18 23:29
Look at line 9 in xasstest.rb
Fd7788760fdcf0cb511f15544f288356?d=identicon&s=25 Priy Nag (newruby901)
on 2014-04-18 23:44
Joel Pearson wrote in post #1143510:
> Look at line 9 in xasstest.rb

require 'securerandom' is the line number 9. Currently, I open the
script in notepad++. Is there any other editor that I can use it to open
from ruby\bin folder?


require 'rubygems'
require 'ecdsa'
require 'securerandom'
require 'json'
require 'base64'
require 'digest'
require 'rest-client'
Fd7788760fdcf0cb511f15544f288356?d=identicon&s=25 Priy Nag (newruby901)
on 2014-04-19 00:38
Priy Nag wrote in post #1143512:
> Joel Pearson wrote in post #1143510:
>> Look at line 9 in xasstest.rb
>
> require 'securerandom' is the line number 9. Currently, I open the
> script in notepad++. Is there any other editor that I can use it to open
> from ruby\bin folder?
>
>
> require 'rubygems'
> require 'ecdsa'
> require 'securerandom'
> require 'json'
> require 'base64'
> require 'digest'
> require 'rest-client'

I needed to install gem ecdsa and rest-client.  Now there is no error.

C:\Ruby193\bin>ruby.exe xasstest.rb
Usage: xasstest.rb <pfx-file> <pfx-passphrase>

C:\Ruby193\bin>
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-04-19 10:07
Notepad++ is my preferred editor for Ruby on Windows. You might want to
try Aptana Studio 3 (RadRails) if you use Rails.
Fd7788760fdcf0cb511f15544f288356?d=identicon&s=25 Priy Nag (newruby901)
on 2014-04-23 00:55
Joel Pearson wrote in post #1143521:
> Notepad++ is my preferred editor for Ruby on Windows. You might want to
> try Aptana Studio 3 (RadRails) if you use Rails.

Can someone help me to fix this issue?  It fails in
client_cert = OpenSSL::PKCS12.new File.read(pfx_file), pfx_pass


xasstest.rb:86:in `initialize': PKCS12_parse: mac verify failure
(OpenSSL::PKCS12::PKCS12Error)

        from xasstest.rb:86:in `new'
        from xasstest.rb:86:in `Test
        from xasstest.rb:130:in `<main>'

Here is the function where the test fails:
-----------------------------------------
def Test(xass_body, xass_headers, pfxFile, pfxPassword)
  xass_url = 'https://service.auth.xboxlive.com/service/authenticate'
  puts "Xass_url is: '#{xass_url}'"
  client_cert = OpenSSL::PKCS12.new File.read(pfxFile), pfxPassword

  rc = RestClient::Resource.new(
    xass_url,
    :ssl_client_cert => client_cert.certificate,
    :ssl_client_key => client_cert.key,
    :verify_ssl => OpenSSL::SSL::VERIFY_PEER
  )

  rc.post(xass_body, xass_headers)
end
Fd7788760fdcf0cb511f15544f288356?d=identicon&s=25 Priy Nag (newruby901)
on 2014-04-24 00:53
Priy Nag wrote in post #1143809:
> Joel Pearson wrote in post #1143521:
>> Notepad++ is my preferred editor for Ruby on Windows. You might want to
>> try Aptana Studio 3 (RadRails) if you use Rails.
>
> Can someone help me to fix this issue?  It fails in
> client_cert = OpenSSL::PKCS12.new File.read(pfx_file), pfx_pass
>
>
> xasstest.rb:86:in `initialize': PKCS12_parse: mac verify failure
> (OpenSSL::PKCS12::PKCS12Error)
>
>         from xasstest.rb:86:in `new'
>         from xasstest.rb:86:in `Test
>         from xasstest.rb:130:in `<main>'
>
> Here is the function where the test fails:
> -----------------------------------------
> def Test(xass_body, xass_headers, pfxFile, pfxPassword)
>   xass_url = 'https://service.auth.xboxlive.com/service/authenticate'
>   puts "Xass_url is: '#{xass_url}'"
>   client_cert = OpenSSL::PKCS12.new File.read(pfxFile), pfxPassword
>
>   rc = RestClient::Resource.new(
>     xass_url,
>     :ssl_client_cert => client_cert.certificate,
>     :ssl_client_key => client_cert.key,
>     :verify_ssl => OpenSSL::SSL::VERIFY_PEER
>   )
>
>   rc.post(xass_body, xass_headers)
> end



Guys,

This is the issue(below url) that I face right now, When I try to update
the below line with "rb" then I get an error cannot convert from string
to integer error.  I'm running this script in Windows(ruby 1.9.3).  It
would be great if someone help me on this.

   client_cert = OpenSSL::PKCS12.new File.read(pfx_file), "rb"),
pfx_pass)

http://stackoverflow.com/questions/10202254/why-op...
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.