[erlang-questions] new_ssl recv Length parameter

Essien Essien essiene@REDACTED
Thu May 21 14:35:10 CEST 2009


On Thu, May 21, 2009 at 1:33 PM, Essien Essien <essiene@REDACTED> wrote:
> Hi all,
>
> I'm having difficulty getting a new_ssl connection to recieve a
> specified Length of data. I've attached two simple server scripts
> oldsslserver.erl uses the old_ssl implimentation, while sslserver.erl
> uses the new_ssl implementation (specifically, it first accepts on tcp
> then upgrades to ssl via ssl_accept).
>
> I have also attached sslclient.erl that connects to each, and attempts
> to send a header that when assembled should look like
> <<"VERSION",2,1>>, but I send I break it up into <<"VERSION">>, <<2>>,
> <<1>> and send them in seperate calls to ssl:send/2. oldsslserver.erl
> is able to nicely assemble this back, but sslserver.erl (using the
> new_ssl implementation) b0rks badly.
>
> I think I may be missing something, but for the life of me, I can't
> figure it out.
>
> erl -man new_ssl says of recv:
>
>              The Length argument is only meaningful when the socket is in raw
>              mode and denotes the number of bytes to read. If Length = 0, all
>              available bytes are returned. If  Length  >  0,  exactly  Length
>              bytes  are  returned, or an error; possibly discarding less than
>              Length bytes of data when the socket gets closed from the  other
>              side.
>
> As you can see in sslserver.erl I have ssl:setopts/2 on the accepted
> ssl socket, to comply with the man page requirement for ssl:recv/2,
> but still... foobar!
>
> Any ideas?
>
> cheers,
> Essien
>
> PS: Before running the scripts, you will need to change that path to
> the SSL certs to point at ones you have created.
> You can generate them with:
>
> $ openssl genrsa 2048 > /path/to/key.pem
> $ openssl req -new -x509 -key /path/to/key.pem -out /path/to/cert.pem
> -nodes -sha1 -batch
>
> Then point the scripts at /path/to/{key,cert}.pem
>

Sorry, replying to myself... I should add that I am using R12B3 with ssl-3.9



More information about the erlang-questions mailing list