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 :wink:

路路路

------------------------------------------------
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/.

Further to this, when I use the following openssl commands to extract
the certificate and key I get a different error:

<SOAP::FaultError: Internal Error>

Inspecting that object gives me the following:

--- !ruby/exception:SOAP::FaultError
message: Internal Error
cause:
detail: ""
faultactor:
faultcode: &id003 !ruby/object:SOAP::SOAPElement
聽聽array: []

聽聽data: []

聽聽definedtype:
聽聽elename: !ruby/object:XSD::QName
聽聽聽聽name: faultcode
聽聽聽聽namespace:
聽聽聽聽source:
聽聽encodingstyle: http://xml.apache.org/xml-soap/literalxml
聽聽extraattr: {}

聽聽id:
聽聽parent: &id001 !ruby/object:SOAP::SOAPFault
聽聽聽聽array:
聽聽聽聽- faultcode
聽聽聽聽- faultstring
聽聽聽聽data:
聽聽聽聽- *id003
聽聽聽聽- &id004 !ruby/object:SOAP::SOAPElement
聽聽聽聽聽聽array: []

聽聽聽聽聽聽data: []

聽聽聽聽聽聽definedtype:
聽聽聽聽聽聽elename: !ruby/object:XSD::QName
聽聽聽聽聽聽聽聽name: faultstring
聽聽聽聽聽聽聽聽namespace:
聽聽聽聽聽聽聽聽source:
聽聽聽聽聽聽encodingstyle: http://xml.apache.org/xml-soap/literalxml
聽聽聽聽聽聽extraattr: {}

聽聽聽聽聽聽id:
聽聽聽聽聽聽parent: *id001
聽聽聽聽聽聽position:
聽聽聽聽聽聽precedents: []

聽聽聽聽聽聽qualified:
聽聽聽聽聽聽root: false
聽聽聽聽聽聽text: Internal Error
聽聽聽聽聽聽type:
聽聽聽聽definedtype:
聽聽聽聽elename: !ruby/object:XSD::QName
聽聽聽聽聽聽name: fault
聽聽聽聽聽聽namespace: http://schemas.xmlsoap.org/soap/envelope/
聽聽聽聽聽聽source:
聽聽聽聽encodingstyle: http://schemas.xmlsoap.org/soap/encoding/
聽聽聽聽extraattr: {}

聽聽聽聽id:
聽聽聽聽parent: &id002 !ruby/object:SOAP::SOAPBody
聽聽聽聽聽聽array:
聽聽聽聽聽聽- fault
聽聽聽聽聽聽data:
聽聽聽聽聽聽- *id001
聽聽聽聽聽聽definedtype:
聽聽聽聽聽聽elename: !ruby/object:XSD::QName
聽聽聽聽聽聽聽聽name: Body
聽聽聽聽聽聽聽聽namespace: http://schemas.xmlsoap.org/soap/envelope/
聽聽聽聽聽聽聽聽source:
聽聽聽聽聽聽encodingstyle:
聽聽聽聽聽聽extraattr: {}

聽聽聽聽聽聽id:
聽聽聽聽聽聽is_fault: true
聽聽聽聽聽聽parent: !ruby/object:SOAP::SOAPEnvelope
聽聽聽聽聽聽聽聽body: *id002
聽聽聽聽聽聽聽聽definedtype:
聽聽聽聽聽聽聽聽elename: !ruby/object:XSD::QName
聽聽聽聽聽聽聽聽聽聽name: Envelope
聽聽聽聽聽聽聽聽聽聽namespace: http://schemas.xmlsoap.org/soap/envelope/
聽聽聽聽聽聽聽聽聽聽source:
聽聽聽聽聽聽聽聽encodingstyle:
聽聽聽聽聽聽聽聽external_content: {}

聽聽聽聽聽聽聽聽extraattr: {}

聽聽聽聽聽聽聽聽header:
聽聽聽聽聽聽聽聽id:
聽聽聽聽聽聽聽聽parent:
聽聽聽聽聽聽聽聽position:
聽聽聽聽聽聽聽聽precedents: []

聽聽聽聽聽聽聽聽qualified:
聽聽聽聽聽聽聽聽root: false
聽聽聽聽聽聽聽聽type:
聽聽聽聽聽聽position:
聽聽聽聽聽聽precedents: []

聽聽聽聽聽聽qualified:
聽聽聽聽聽聽root: false
聽聽聽聽聽聽type: !ruby/object:XSD::QName
聽聽聽聽聽聽聽聽name:
聽聽聽聽聽聽聽聽namespace:
聽聽聽聽聽聽聽聽source:
聽聽聽聽position:
聽聽聽聽precedents: []

聽聽聽聽qualified:
聽聽聽聽root: false
聽聽聽聽type: !ruby/object:XSD::QName
聽聽聽聽聽聽name: Fault
聽聽聽聽聽聽namespace: http://schemas.xmlsoap.org/soap/envelope/
聽聽聽聽聽聽source:
聽聽position:
聽聽precedents: []

聽聽qualified:
聽聽root: false
聽聽text: General
聽聽type:
faultstring: *id004
original_backtrace:

Confused...

路路路

--
Posted via http://www.ruby-forum.com/.

bump.

路路路

--
Posted via http://www.ruby-forum.com/.