[erlang-questions] asn1 and the new ssl module

Pablo Polvorin <>
Wed Feb 20 20:25:18 CET 2008


Hi,
thanks for the patch!
perhaps i had been doing something wrong, but i couldn't make your
patch work for my.
Immediately after upgrading a gen_tcp socket to ssl, I get this error
{function_clause,
                        [{ssl_connection,check_packet,[asn1,<<>>,0]..

After fixing this adding a new case to check_packet(asn1,..), it still
doesn't work, and returns data that is not an asn1-completed packet.

Digging in the ber encoding documentation and
asn1rt_ber_bin:decode_tag_and_length/1, each packet seems to looks
like <<Tag,PacketLength,Packet>>, where the size of the Tag field
isn't know, and the size of the PacketLength field could be anything
between 1 and 128 bytes.  Are you taking this into account?

Here is my version of a patch(R12B-1) for this, its based in my
previous code (and so depends on the asn1 application.. witch is
somewhat awkward as the api for decode_tag_and_length/1 doesn't define
what error it would throw when the tag or length field isn't
complete).

best regards, pablo.



2008/2/20, Jakob Cederlund <>:
>
>  thisIt was very useful, thanks!
>  And here is a patch. It simply adds asn1 package support for the new ssl.
> It should work with R12B-1, and probably fine with R12B.
>  Hope this helps!
>  /Jakob
>
>
>
>  Pablo Polvorin wrote:
>  Thanks for the clarification!
>
> ...it isn't a patch, .. probably it isn't usefull to you. .
> anyway, this is the code i'm using
> http://ppolv.wordpress.com/2008/02/15/erlang-ssl-and-asn1/
>
> cheers
> pablo
>
> 2008/2/15, Jakob Cederlund <>:
>
>
>  Nope, not yet.
>  Currently, the new ssl (the one you get with {ssl_imp, new}) only
>  supports these packet-options: raw, 1, 2, 4, cdr and line. (Packaging is
>  handled by the function ssl_connection:check_packet/3.) The rest are
>  fairly easy to add, and we hope to do that in the next release. Patches
>  are welcome! :-)
>
> /Jakob
>
>
>  Pablo Polvorin wrote:
>  > Hi all,
>  > I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But
>  > I couldn't find a way to easily receiving asn1 packets from it.
>  > My question is, it's possible to use the {packet,asn1} option when
>  > using the new ssl module?.
>  >
>  > ssl_connection.erl seems to not have any reference to that option.
>  >
>  > Finally I implemented the buffering and packet delimiting code in my
>  > application, but I wonder if there is an easy and early way to
>  > accomplish the same.
>  > regards,
>  >
>
>
>
>
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ssl_asn1_myversion.patch
Type: text/x-diff
Size: 2368 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080220/78e15009/attachment.bin>


More information about the erlang-questions mailing list