lib/net/ber.rb in ruby-net-ldap-0.0.2 vs lib/net/ber.rb in ruby-net-ldap-0.0.3

- old
+ new

@@ -1,6 +1,6 @@ -# $Id: ber.rb 93 2006-05-01 06:40:48Z blackhedd $ +# $Id: ber.rb 142 2006-07-26 12:20:33Z blackhedd $ # # NET::BER # Mixes ASN.1/BER convenience methods into several standard classes. # Also provides BER parsing functionality. # @@ -137,9 +137,25 @@ require "stringio" class StringIO include Net::BER::BERParser end +begin + require 'openssl' + class OpenSSL::SSL::SSLSocket + include Net::BER::BERParser + end +rescue LoadError +# Ignore LoadError. +# DON'T ignore NameError, which means the SSLSocket class +# is somehow unavailable on this implementation of Ruby's openssl. +# This may be WRONG, however, because we don't yet know how Ruby's +# openssl behaves on machines with no OpenSSL library. I suppose +# it's possible they do not fail to require 'openssl' but do not +# create the classes. So this code is provisional. +# Also, you might think that OpenSSL::SSL::SSLSocket inherits from +# IO so we'd pick it up above. But you'd be wrong. +end class String def read_ber syntax=nil StringIO.new(self).read_ber(syntax) end