From: Ed James Date: 2009-07-18T01:00:33+09:00 Subject: soap4r, ssl and certificates problem 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() @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/.