theGreenCabbage
theGreenCabbage

Reputation: 4845

How to get the ssl_version of a Ruby SSLContext object

I am working on OpenSSL's SSLContext right now and created a Ruby OpenSSL object like this:

0> ssl_object = OpenSSL::SSL::SSLContext.new("TLSv1_2_client")
=> #<OpenSSL::SSL::SSLContext:0x7acec6db>

which created an instance of the SSLContext object. I can change this SSLContext object by using:

ssl_object.ssl_version="SSLv2_3"

However, I want to understand/get that ssl_version of ssl_object. How do I do that?

When I do:

0> ssl_object.ssl_version
=> undefined method `ssl_version' for #<OpenSSL::SSL::SSLContext:0x38106bc4>
Did you mean?  ssl_version=

According to the documentation, there's only a setter, not a getter.

Upvotes: 2

Views: 384

Answers (1)

Bart
Bart

Reputation: 2656

Looks like you can create a fake socket:

OpenSSL::SSL::SSLSocket.new(
  UNIXSocket.pair.first, 
  OpenSSL::SSL::SSLContext.new("SSLv3")
).ssl_version
=> "SSLv3"

Upvotes: 2

Related Questions