Hi
I'm trying to consume a SOAP service that is on an ssl endpoint. The
security is public/private key.
What I have so far:
I have the wsdl for the service, together with the CA certificate and a
.pfx file which I believe contains everything I need. I have client ruby
classes which have been generated using the wsdl2ruby command line tool.
I have the soap4r gem 1.5.8 installed.
This is my code (forgive the clunkyness - it's for testing
路路路
------------------------------------------------
require 'rubygems'
gem 'soap4r'
require 'defaultDriver.rb'
class WS
聽聽def initialize
聽聽聽聽@context = CommonServiceContext.new(<various setup variables>)
聽聽聽聽@param = SearchCompanyByEHId.new('2272357', @context)
聽聽聽聽@driver = CompanySearchServiceV5.new
聽聽聽聽@driver.loadproperty('ssl.properties')
聽聽end
聽聽def do
聽聽聽聽begin
聽聽聽聽聽聽@driver.searchCompanyByEHId(@param)
聽聽聽聽rescue Exception => e
聽聽聽聽聽聽return e
聽聽聽聽end
聽聽end
end
------------------------------------------------
This is what my 'ssl.properties' file looks like:
------------------------------------------------
protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
protocol.http.ssl_config.ca_file = ca.cer
protocol.http.ssl_config.client_cert = usercert.pem
protocol.http.ssl_config.client_key = userkey.pem
protocol.http.ssl_config.ciphers = ALL
protocol.http.ssl_config.verify_depth = 1
------------------------------------------------
I tried using openssl to extract my key and certificate from the pfx
file, using these commands:
openssl pkcs12 -nocerts -in my_pfx.pfx -out userkey.key
openssl pkcs12 -clcerts -nokeys -in my_pfx.pfx -out usercert.cert
I don't get any errors so I assume that it's all ok at this point.
When I run my class, I get the following error:
OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key:: nested asn1
error
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/httpconfigloader.rb:134:in
`initialize'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/httpconfigloader.rb:134:in
`new'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/httpconfigloader.rb:134:in
`key_from_file'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/httpconfigloader.rb:90:in
`set_ssl_config'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:140:in
`each'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:139:in
`each'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/httpconfigloader.rb:81:in
`set_ssl_config'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/httpconfigloader.rb:36:in
`set_options'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:115:in
`call'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:115:in
`[]='
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:114:in
`each'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:114:in
`[]='
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:84:in
`load'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/driver.rb:232:in
`each_with_index'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:73:in
`each'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:73:in
`each_with_index'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:73:in
`load'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:309:in
`loadpropertyfile'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:308:in
`open'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:308:in
`loadpropertyfile'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/property.rb:95:in
`loadproperty'
聽聽from
/usr/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/driver.rb:120:in
`loadproperty'
聽聽from ./ws.rb:21:in `initialize'
聽聽from (irb):8:in `new'
Has anyone managed to get this kind of thing working. I'm struggling to
find any detailed examples or explanations (beyond the usual
basic_http_auth stuff) that have helped me.
Any help or pointers would be greatly appreciated.
Thanks.
--
Posted via http://www.ruby-forum.com/.