Forum: Ruby ssl xml rpc

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
51763ff4e4c531c68326064bc13b84a6?d=identicon&s=25 David Weldon (5hundy)
on 2007-01-24 08:58
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"?>
<transaction>
  <methodCall>
  ...blah blah...
  </methodCall>
</transaction>
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!
E0c987f680cd640c14912ebfbf0f0f07?d=identicon&s=25 unknown (Guest)
on 2007-01-24 16:29
(Received via mailing list)
On 1/24/07, David Weldon <dweldon@gmail.com> 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.
51763ff4e4c531c68326064bc13b84a6?d=identicon&s=25 David Weldon (5hundy)
on 2007-01-25 00:57
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
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?
Ff9e18f0699bf079f1fc91c8d4506438?d=identicon&s=25 James Britt (Guest)
on 2007-01-25 04:13
(Received via mailing list)
David Weldon 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 Britt

http://www.ruby-doc.org    - Ruby Help & Documentation
http://beginningruby.com   - Beginning Ruby: The Online Book
http://www.rubystuff.com   - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com  - Playing with Better Toys
51763ff4e4c531c68326064bc13b84a6?d=identicon&s=25 David Weldon (5hundy)
on 2007-01-25 06:40
> 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.
E0c987f680cd640c14912ebfbf0f0f07?d=identicon&s=25 unknown (Guest)
on 2007-01-25 15:50
(Received via mailing list)
On 1/25/07, David Weldon <dweldon@gmail.com> 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.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/librar...
        if(BIO_write(bio, buf, len) <= 0)
        {
        }
E0c987f680cd640c14912ebfbf0f0f07?d=identicon&s=25 unknown (Guest)
on 2007-01-25 15:58
(Received via mailing list)
On 1/25/07, brabuhr@gmail.com <brabuhr@gmail.com> wrote:
> On 1/25/07, David Weldon <dweldon@gmail.com> 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/fid5E43597C85CD23E775CC...
    s = TCPSocket.new(...)
    ssl = OpenSSL::SSL::SSLSocket.new(...)

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

    ssl.close
    s.close
51763ff4e4c531c68326064bc13b84a6?d=identicon&s=25 David Weldon (5hundy)
on 2007-01-25 20:55
http://www.koders.com/ruby/fid5E43597C85CD23E775CC...
>     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
This topic is locked and can not be replied to.