# Ssl xml rpc

**URL:** <https://www.ruby-forum.com/t/ssl-xml-rpc/83198>\
**Category:** Ruby\
**Created:** [January 24, 2007, 8:58am UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198 "2007-01-24T08:58:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 24, 2007, 8:58am UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/1 "2007-01-24T08:58:30Z")

</div>

I need to make remote procedure calls to a server that has a  
non-standard RPC protocol. It’s basically RPC but with extra types, no  
required message length declaration and it’s all done over ssl. I have a  
working version in perl but I’d prefer a solution in ruby. Below is what  
I have so far with most of the XML removed for brevity.

require ‘rubygems’  
require ‘http-access2’  
client = HTTPAccess2::Client.new()  
client.ssl\_config.verify\_mode = nil

body = \<\<ENDXML

\<?xml version="1.0"?\> ...blah blah... ENDXML resp = client.post("https://api.ultradns.net:8755",body)

Whenever I try to talk to the server it always replies that I have a  
malformed POST. I’m using http-access2; someone packaged it as a gem but  
its not in the official repository. I’d like to know:

1. Is there a better way of doing all of this? (something other than  
http-access2)
2. Is there something obviously wrong with the above code? Keep in mind  
the XML part is verified in a working perl script.

Thanks!

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 24, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/2 "2007-01-24T16:29:21Z")

</div>

On 1/24/07, David W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the XML part is verified in a working perl script.  
> In situations like this I often find a network protocol analyzer like  
> Wireshark  
> very helpful. I would start a packet capture filtering on port 8755 and  
> run  
> both versions of the script (either in one capture session or two,  
> probably  
> two). Then, for both captured streams in Wireshark: Analyze → Follow  
> TCP  
> Stream. That should present a nice view of the POST request sent by  
> each  
> script.

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 25, 2007, 12:57am UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/3 "2007-01-25T00:57:27Z")

</div>

Ok I think I discovered the problem. I need to send my XML directly  
without any headers. Right now I’m sending something like:

POST /RPC2 HTTP/1.0  
User-Agent: Frontier/5.1.2 (WinNT)  
Host: [betty.userland.com](http://betty.userland.com)  
Content-Type: text/xml  
Content-length: 181

and the response I’m getting is that “POST /RPC2 HTTP/1.0” isn’t valid  
XML. 🙂 So my new question is:

Does anyone know a way to write raw xml data to a given server&port with  
ssl? In other words do you know how to send a POST over ssl without the  
headers?

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 25, 2007, 4:13am UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/4 "2007-01-25T04:13:30Z")

</div>

David W. wrote:

> XML. 🙂 So my new question is:
> 
> Does anyone know a way to write raw xml data to a given server&port with  
> ssl? In other words do you know how to send a POST over ssl without the  
> headers?

I think that, by definition, a POST has POST headers.

What’s running on the server, and why isn’t it looking at the post data,  
instead of the HTTP headers?

–  
James B.

[http://www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
[http://beginningruby.com](http://beginningruby.com) - Beginning Ruby: The Online Book  
[http://www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
[http://www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 25, 2007, 6:40am UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/5 "2007-01-25T06:40:34Z")

</div>

> I think that, by definition, a POST has POST headers.

Haha, yeah I agree.

> What’s running on the server, and why isn’t it looking at the post data,  
> instead of the HTTP headers?

Man I have no idea; it isn’t my server but I have to talk to it. I have  
a solution that involves hacking up the http-access2 code so it doesn’t  
dump the header. If anyone has done anything like writing raw data to an  
ssl connection let me know.

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 25, 2007, 3:50pm UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/6 "2007-01-25T15:50:22Z")

</div>

On 1/25/07, David W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > What’s running on the server, and why isn’t it looking at the post data,  
> > instead of the HTTP headers?
> 
> Man I have no idea; it isn’t my server but I have to talk to it. I have  
> a solution that involves hacking up the http-access2 code so it doesn’t  
> dump the header. If anyone has done anything like writing raw data to an  
> ssl connection let me know.

I’ve not done it in Ruby, but some C examples:  
[An Introduction to OpenSSL Programming, Part I of II | Linux Journal](http://www.linuxjournal.com/article/4822)  
request\_len=strlen(request);  
r=SSL\_write(ssl,request,request\_len);  
switch(SSL\_get\_error(ssl,r)){  
}

```
http://www-128.ibm.com/developerworks/linux/library/l-openssl.html
    if(BIO_write(bio, buf, len) <= 0)
    {
    }

```

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 25, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/7 "2007-01-25T15:58:25Z")

</div>

On 1/25/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 1/25/07, David W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > What’s running on the server, and why isn’t it looking at the post data,  
> > > instead of the HTTP headers?
> > 
> > Man I have no idea; it isn’t my server but I have to talk to it. I have  
> > a solution that involves hacking up the http-access2 code so it doesn’t  
> > dump the header. If anyone has done anything like writing raw data to an  
> > ssl connection let me know.
> 
> I’ve not done it in Ruby, but some C examples:

[http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.aspx?s=socket](http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.aspx?s=socket)  
s = TCPSocket.new(…)  
ssl = OpenSSL::SSL::SSLSocket.new(…)

```
ssl.connect
ssl.write(...)
ssl.gets

ssl.close
s.close

```

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [January 25, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/ssl-xml-rpc/83198/8 "2007-01-25T20:55:50Z")

</div>

[http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.aspx?s=socket](http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.aspx?s=socket)

> ```
> s = TCPSocket.new(...)
> ssl = OpenSSL::SSL::SSLSocket.new(...)
> 
> ssl.connect
> ssl.write(...)
> ssl.gets
> 
> ssl.close
> s.close
> 
> ```

Fantastic! That worked just great. Thanks for the replies everyone!

-Dave
