# OpenSSL , SOAP4R

**URL:** <https://www.ruby-forum.com/t/openssl-soap4r/86458>\
**Category:** Ruby\
**Created:** [February 22, 2007, 1:47pm UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458 "2007-02-22T13:47:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 22, 2007, 1:47pm UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/1 "2007-02-22T13:47:59Z")

</div>

Hi guys,  
Does someone knows how to use certificates with SOAP::WSDLDriverFactory  
?  
for example, to generate a driver from a url like:  
[https://some.com/something.wsl](https://some.com/something.wsl)

Tks in advance  
Ze Maria

---

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 22, 2007, 9:52pm UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/2 "2007-02-22T21:52:38Z")

</div>

Ze Maria wrote:

> Hi guys,  
> Does someone knows how to use certificates with SOAP::WSDLDriverFactory  
> ?  
> for example, to generate a driver from a url like:  
> [https://some.com/something.wsl](https://some.com/something.wsl)
> 
> Tks in advance  
> Ze Maria

If you don’t have the CA, you can do:

server.options[“protocol.http.ssl\_config.verify\_mode”] = nil

Or are you referring to use CERTS to authenticate?

---

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 23, 2007, 11:08am UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/3 "2007-02-23T11:08:10Z")

</div>

Justin M. wrote:

> Ze Maria wrote:
> 
> > Hi guys,  
> > Does someone knows how to use certificates with SOAP::WSDLDriverFactory  
> > ?  
> > for example, to generate a driver from a url like:  
> > [https://some.com/something.wsl](https://some.com/something.wsl)
> > 
> > Tks in advance  
> > Ze Maria
> 
> If you don’t have the CA, you can do:
> 
> server.options[“protocol.http.ssl\_config.verify\_mode”] = nil
> 
> Or are you referring to use CERTS to authenticate?

if the certificate (.crt) , I don’t understanding how do you 've a  
variable named “server” with an options hash…

Tks  
Ze Maria

---

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 23, 2007, 5:05pm UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/4 "2007-02-23T17:05:11Z")

</div>

> > server.options[“protocol.http.ssl\_config.verify\_mode”] = nil

> if the certificate (.crt) , I don’t understanding how do you 've a  
> variable named “server” with an options hash…

Hopefully this may clarify,

wsdl = ‘[https://some.com/something.wsl](https://some.com/something.wsl)’  
factory = SOAP::WSDLDriverFactory.new( wsdl )  
drv = factory.create\_rpc\_driver  
drv.options[‘protocol.http.ssl\_config.ca\_file’] = nil

alternatively:

drv.options[‘protocol.http.ssl\_config.verify\_mode’] =  
openSSL::SSL::VERIFY\_NONE

some other possibly useful options:

drv.options[‘protocol.http.ssl\_config.verify\_mode’] =  
OpenSSL::SSL::VERIFY\_PEER  
drv.options[‘protocol.http.ssl\_config.ca\_file’] = ‘api\_cert\_chain.crt’  
drv.options[‘protocol.http.ssl\_config.client\_cert’] = ‘client.cert’  
drv.options[‘protocol.http.ssl\_config.client\_key’] = ‘client.keys’

---

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 23, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/5 "2007-02-23T18:16:24Z")

</div>

On Feb 23, 7:04 am, “Mike Wernsing” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> alternatively:
> 
> drv.options[‘protocol.http.ssl\_config.verify\_mode’] = openSSL::SSL::VERIFY\_NONE
> 
> some other possibly useful options:
> 
> drv.options[‘protocol.http.ssl\_config.verify\_mode’] = OpenSSL::SSL::VERIFY\_PEER  
> drv.options[‘protocol.http.ssl\_config.ca\_file’] = ‘api\_cert\_chain.crt’  
> drv.options[‘protocol.http.ssl\_config.client\_cert’] = ‘client.cert’  
> drv.options[‘protocol.http.ssl\_config.client\_key’] = ‘client.keys’

This is good stuff! What would be a good link to have found this for  
myself? Thanks!

Mike B.

---

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 23, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/6 "2007-02-23T20:07:40Z")

</div>

> This is good stuff! What would be a good link to have found this for  
> myself? Thanks!

Might try these:

[http://calagenda.berkeley.edu/calendar-ws/sample-code.html](http://calagenda.berkeley.edu/calendar-ws/sample-code.html)

The following describes using wsdl2ruby:  
[http://www.pranavbihari.com/articles/2005/12/02/testing-paypal-web-services-with-ruby-soap4r](http://www.pranavbihari.com/articles/2005/12/02/testing-paypal-web-services-with-ruby-soap4r)

---

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [February 24, 2007, 7:04am UTC](https://www.ruby-forum.com/t/openssl-soap4r/86458/7 "2007-02-24T07:04:27Z")

</div>

Mike Wernsing wrote:

> > > server.options[“protocol.http.ssl\_config.verify\_mode”] = nil
> 
> > if the certificate (.crt) , I don’t understanding how do you 've a  
> > variable named “server” with an options hash…
> 
> Hopefully this may clarify,
> 
> wsdl = ‘[https://some.com/something.wsl](https://some.com/something.wsl)’  
> factory = SOAP::WSDLDriverFactory.new( wsdl )  
> drv = factory.create\_rpc\_driver  
> drv.options[‘protocol.http.ssl\_config.ca\_file’] = nil
> 
> alternatively:
> 
> drv.options[‘protocol.http.ssl\_config.verify\_mode’] =  
> openSSL::SSL::VERIFY\_NONE
> 
> some other possibly useful options:
> 
> drv.options[‘protocol.http.ssl\_config.verify\_mode’] =  
> OpenSSL::SSL::VERIFY\_PEER  
> drv.options[‘protocol.http.ssl\_config.ca\_file’] = ‘api\_cert\_chain.crt’  
> drv.options[‘protocol.http.ssl\_config.client\_cert’] = ‘client.cert’  
> drv.options[‘protocol.http.ssl\_config.client\_key’] = ‘client.keys’

Should be noted that the above actually does not checks the actual  
server (peer) certificate. It only validates that the peer certificate  
is signed by / issued by the ‘api\_cert\_chain.crt’.

To actually validate the server cert use :  
drv.options[‘protocol.http.ssl\_config.verify\_callback’] =  
method(:validate\_certificate)

where method validate\_certificate looks like:

def validate\_certificate(is\_ok, ctx)  
cert = ctx.current\_cert

# Only check the server certificate, not the issuer

unless (cert.subject.to\_s == cert.issuer.to\_s)  
is\_ok &&= File.open(‘server\_cert.pem’).read ==  
ctx.current\_cert.to\_pem  
end  
is\_ok  
end

emil
