ssl xml rpc

D

David Weldon

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!
 
B

brabuhr

I need to make remote procedure calls to a server that has a
non-standard RPC protocol. ...

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.

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

David Weldon

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?
 
J

James Britt

David said:
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?

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
 
D

David Weldon

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

brabuhr

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/library/l-openssl.html
if(BIO_write(bio, buf, len) <= 0)
{
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top