Hi list.
I've decided to jump in and integrate OpenSRS stuff into our environment.
Taking baby steps, I wanted to just whip up a test script that verifies I
can indeed connect to the server and speak it's language. Apparently, I
can't. :)
I'm hoping someone can lend some insight to the error I'm getting. I
searched through past archives, and the only mention of this error is from
2 years ago - and it was due to an incompatible version of Blowfish (2.07).
This was supposedly fixed in 2.08 - I'm using 2.09.
The exact error the server spits at me is:
'OPS Decode Error: Envelope Protocol Not Supported'
This is the case for the staging environment (horizon) and live.
I've verified my key as being correct. I get no error at all (server drops
me) if I send a purposely incorrect key - this is expected behavior
according to the API documentation.
Using the OPS.pm from the 2.78 opensrs tarball. Here are some other
relevant versions:
XML-Parser-2.34
Crypt-CBC-2.08
Digest-MD5-2.27
MD5-2.02
Crypt-Blowfish-2.09
The rather simple test script I am using is below, sensitive info
masked out. Did I just miss an obvious step somewhere along the
way?
Any hints/tips/gentle smacks to the noggin' are appreciated.
-Mahlon
Mahlon E. Smith jabber id: mahlon@chat.martini.nu
http://www.martini.nu/ get pgp key: mahlon-pgp@martini.nu
........................................................................
From the earths's foul gut - Belched forth this plate of meat now;
Moist hatchling playground - Dave van Zijl
----------------------------------------------------------------------
#!/usr/bin/perl -w
#
# Test connect to the OpenSRS network.
# -------------------------------------------------------
use strict;
use lib '/usr/local/lib/OpenSRS';
use OPS;
use IO::Socket;
use Crypt::CBC;
use Digest::MD5 qw(md5);
use vars qw($ops $r $s $srs_server $pw);
#-----
my $un = '****';
# test
$srs_server = 'horizon.opensrs.net';
$pw = '****';
# live
#$srs_server = 'rr-n1-tor.opensrs.net';
#$pw = '*****';
# Connect to server
$ops = new OPS();
$s = IO::Socket::INET->new(
Proto => 'tcp',
PeerAddr => $srs_server,
PeerPort => 55000);
die "Unable to connect to OpenSRS server.\n" unless $s;
select($s); $| = 1;
select(STDOUT);
#-----
# Version checking first.
# Nothing is encrypted at this stage of the game.
$r = $ops->read_message($s); # server tells us it's version
# Is this client allowed to connect?
if (($r->{response_code}) && ($r->{response_code} == 555)) {
die "$r->{response_text}\n";
}
# Is the remote server sane?
if ($r->{attributes}->{sender} !~ /OpenSRS\sSERVER/ ||
$r->{attributes}->{version} !~ /^XML/ ) {
die "Unrecognized response from server.\n";
}
# Ok so far. Send our client version.
$ops->write_message($s,{
action => 'check',
object => 'version',
attributes => {
sender => 'OpenSRS CLIENT',
version => 'XML:0.1',
state => 'ready'
}
});
#-----
# Authentication handshake.
# First, send challenge request.
$ops->write_message($s,{
action => 'authenticate',
object => 'user',
attributes => {
crypt_type => 'blowfish',
username => $un,
password => $un
}
});
# The server sends a challenge at this point.
# In order for the connection to continue, the challenge
# needs to be md5 checksummed, encrypted with our private key,
# and returned.
my $challenge = md5($ops->read_data($s));
my $cipher = new Crypt::CBC(pack('H*', $pw), 'Blowfish');
$challenge = $cipher->encrypt($challenge);
$ops->write_data($s, $challenge);
$r = $ops->read_message($s); # did we auth ok?
## SOMETHING AIN'T RIGHT. DEBUG OUTPUT...
print $r->{protocol} . "\n";
print $r->{action} . "\n";
print $r->{response_code} . "\n";
print $r->{response_text} . "\n";
close($s);
exit(0);
This archive was generated by hypermail 2.1.3 : Tue Oct 19 2004 - 23:37:48 EDT