Module: RubyTls::SSL

Extended by:
FFI::Library
Defined in:
lib/ruby-tls/ssl.rb

Defined Under Namespace

Classes: Box, Context

Constant Summary collapse

SSL_ST_OK =
0x03
BIO_CTRL_PENDING =

opt - is their more data buffered?

10
SSL_CTRL_OPTIONS =
32
SSL_CTRL_MODE =
33
SSL_CTRL_SET_SESS_CACHE_SIZE =
42
SSL_CTRL_SET_TLSEXT_HOSTNAME =
55
SSL_CTRL_SET_TLSEXT_SERVERNAME_CB =
53
TLSEXT_NAMETYPE_host_name =
0
SSL_TLSEXT_ERR_OK =
0
SSL_TLSEXT_ERR_ALERT_WARNING =
1
SSL_TLSEXT_ERR_ALERT_FATAL =
2
SSL_TLSEXT_ERR_NOACK =
3
PrivateMaterials =
<<-keystr
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDCYYhcw6cGRbhBVShKmbWm7UVsEoBnUf0cCh8AX+MKhMxwVDWV
Igdskntn3cSJjRtmgVJHIK0lpb/FYHQB93Ohpd9/Z18pDmovfFF9nDbFF0t39hJ/
AqSzFB3GiVPoFFZJEE1vJqh+3jzsSF5K56bZ6azz38VlZgXeSozNW5bXkQIDAQAB
AoGALA89gIFcr6BIBo8N5fL3aNHpZXjAICtGav+kTUpuxSiaym9cAeTHuAVv8Xgk
H2Wbq11uz+6JMLpkQJH/WZ7EV59DPOicXrp0Imr73F3EXBfR7t2EQDYHPMthOA1D
I9EtCzvV608Ze90hiJ7E3guGrGppZfJ+eUWCPgy8CZH1vRECQQDv67rwV/oU1aDo
6/+d5nqjeW6mWkGqTnUU96jXap8EIw6B+0cUKskwx6mHJv+tEMM2748ZY7b0yBlg
w4KDghbFAkEAz2h8PjSJG55LwqmXih1RONSgdN9hjB12LwXL1CaDh7/lkEhq0PlK
PCAUwQSdM17Sl0Xxm2CZiekTSlwmHrtqXQJAF3+8QJwtV2sRJp8u2zVe37IeH1cJ
xXeHyjTzqZ2803fnjN2iuZvzNr7noOA1/Kp+pFvUZUU5/0G2Ep8zolPUj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jYPICCkMIHfBgNV
HSMEgdcwgdSAFPJvPd1Fcmd8o/Tm88r+NjYPICCkoYGwpIGtMIGqMQswCQYDVQQG
EwJVUzERMA8GA1UECBMITmV3IFlvcmsxETAPBgNVBAcTCE5ldyBZb3JrMRYwFAYD
VQQKEw1TdGVhbWhlYXQubmV0MRQwEgYDVQQLEwtFbmdpbmVlcmluZzEdMBsGA1UE
AxMUb3BlbmNhLnN0ZWFtaGVhdC5uZXQxKDAmBgkqhkiG9w0BCQEWGWVuZ2luZWVy
aW5nQHN0ZWFtaGVhdC5uZXSCCQDZuFv087PrPjAMBgNVHRMEBTADAQH/MA0GCSqG
SIb3DQEBBQUAA4GBAC1CXey/4UoLgJiwcEMDxOvW74plks23090iziFIlGgcIhk0
Df6hTAs7H3MWww62ddvR8l07AWfSzSP5L6mDsbvq7EmQsmPODwb6C+i2aF3EDL8j
uw73m4YIGI0Zw2XdBpiOGkx2H56Kya6mJJe/5XORZedh1wpI7zki01tHYbcy
-----END CERTIFICATE-----
keystr
BuiltinPasswdCB =
FFI::Function.new(:int, [:pointer, :int, :int, :pointer]) do |buffer, len, flag, data|
    buffer.write_string('kittycat')
    8
end
DEFAULT_PRIVATE =
pointer.get_pointer(0)
DEFAULT_CERT =
pointer.get_pointer(0)
SSL_MODE_RELEASE_BUFFERS =

Save RAM by releasing read and write buffers when they're empty

0x00000010
SSL_OP_ALL =
0x80000BFF
SSL_FILETYPE_PEM =
1

Class Method Summary collapse

Class Method Details

.BIO_pending(bio) ⇒ Object


93
94
95
# File 'lib/ruby-tls/ssl.rb', line 93

def self.BIO_pending(bio)
    BIO_ctrl(bio, BIO_CTRL_PENDING, 0, nil)
end

.SSL_CTX_sess_set_cache_size(ssl_ctx, op) ⇒ Object


177
178
179
# File 'lib/ruby-tls/ssl.rb', line 177

def self.SSL_CTX_sess_set_cache_size(ssl_ctx, op)
    SSL_CTX_ctrl(ssl_ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, op, nil)
end

.SSL_CTX_set_mode(ssl_ctx, op) ⇒ Object


173
174
175
# File 'lib/ruby-tls/ssl.rb', line 173

def self.SSL_CTX_set_mode(ssl_ctx, op)
    SSL_CTX_ctrl(ssl_ctx, SSL_CTRL_MODE, op, nil)
end

.SSL_CTX_set_options(ssl_ctx, op) ⇒ Object


169
170
171
# File 'lib/ruby-tls/ssl.rb', line 169

def self.SSL_CTX_set_options(ssl_ctx, op)
    SSL_CTX_ctrl(ssl_ctx, SSL_CTRL_OPTIONS, op, nil)
end

.SSL_CTX_set_tlsext_servername_callback(ctx, callback) ⇒ Object


193
194
195
# File 'lib/ruby-tls/ssl.rb', line 193

def self.SSL_CTX_set_tlsext_servername_callback(ctx, callback)
    SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, callback)
end

.SSL_set_tlsext_host_name(ssl, host_name) ⇒ Object


183
184
185
186
# File 'lib/ruby-tls/ssl.rb', line 183

def self.SSL_set_tlsext_host_name(ssl, host_name)
    name = FFI::MemoryPointer.from_string(host_name)
    SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name)
end