Like Kgio::SSL, but for SSL/TLS clients that connect to servers, not for SSL/TLS servers.
Initializes an SSL/TLS client socket. Like Kgio::SSL.new, except hostname is required for verification and session may be specified as an OpenSSL::SSL::Session object.
static VALUE conn_init(int argc, VALUE *argv, VALUE self)
{
VALUE io, ctx, hostname, session;
SSL *ssl;
rb_scan_args(argc, argv, "31", &io, &ctx, &hostname, &session);
ssl = kgio_ssl_init(self, io, ctx);
if (SSL_set_tlsext_host_name(ssl, StringValueCStr(hostname)) != 1)
ossl_raise(eSSLError, "SSL_set_tlsext_host_name");
if (rb_obj_is_kind_of(session, cSSLSession)) {
SSL_SESSION *sess = DATA_PTR(session);
if (!sess)
ossl_raise(eSSLSession, "no session available");
if (SSL_set_session(ssl, sess) != 1)
ossl_raise(eSSLError, "SSL_set_session");
}
rb_ivar_set(self, iv_hostname, hostname);
rb_ivar_set(self, iv_kgio_connected, Qfalse);
return conn_tryconnect(self);
}
Originally generated with the Darkfish Rdoc Generator 2, modified by wrongdoc.
We love to hear from you!