~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to ext/openssl/ossl_ssl.c

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: ossl_ssl.c 23211 2009-04-19 13:32:18Z yugui $
 
2
 * $Id: ossl_ssl.c 27976 2010-05-23 12:18:51Z yugui $
3
3
 * 'OpenSSL for Ruby' project
4
4
 * Copyright (C) 2000-2002  GOTOU Yuuzou <gotoyuzo@notwork.org>
5
5
 * Copyright (C) 2001-2002  Michal Rokos <m.rokos@sh.cvut.cz>
16
16
#  include <unistd.h> /* for read(), and write() */
17
17
#endif
18
18
 
19
 
#define numberof(ary) (sizeof(ary)/sizeof(ary[0]))
 
19
#define numberof(ary) (int)(sizeof(ary)/sizeof(ary[0]))
20
20
 
21
21
#ifdef _WIN32
22
22
#  define TO_SOCKET(s) _get_osfhandle(s)
67
67
    "verify_callback", "options", "cert_store", "extra_chain_cert",
68
68
    "client_cert_cb", "tmp_dh_callback", "session_id_context",
69
69
    "session_get_cb", "session_new_cb", "session_remove_cb",
 
70
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
 
71
    "servername_cb",
 
72
#endif
70
73
};
71
74
 
72
75
#define ossl_ssl_get_io(o)           rb_iv_get((o),"@io")
84
87
#define ossl_ssl_set_tmp_dh(o,v)     rb_iv_set((o),"@tmp_dh",(v))
85
88
 
86
89
static const char *ossl_ssl_attr_readers[] = { "io", "context", };
87
 
static const char *ossl_ssl_attrs[] = { "sync_close", };
 
90
static const char *ossl_ssl_attrs[] = {
 
91
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
 
92
    "hostname",
 
93
#endif
 
94
    "sync_close",
 
95
};
88
96
 
89
97
ID ID_callback_state;
90
98
 
95
103
    const char *name;
96
104
    SSL_METHOD *(*func)(void);
97
105
} ossl_ssl_method_tab[] = {
98
 
#define OSSL_SSL_METHOD_ENTRY(name) { #name, name##_method }
 
106
#define OSSL_SSL_METHOD_ENTRY(name) { #name, (SSL_METHOD *(*)(void))name##_method }
99
107
    OSSL_SSL_METHOD_ENTRY(TLSv1),
100
108
    OSSL_SSL_METHOD_ENTRY(TLSv1_server),
101
109
    OSSL_SSL_METHOD_ENTRY(TLSv1_client),
296
304
ossl_call_session_get_cb(VALUE ary)
297
305
{
298
306
    VALUE ssl_obj, sslctx_obj, cb;
299
 
    
 
307
 
300
308
    Check_Type(ary, T_ARRAY);
301
309
    ssl_obj = rb_ary_entry(ary, 0);
302
310
 
343
351
ossl_call_session_new_cb(VALUE ary)
344
352
{
345
353
    VALUE ssl_obj, sslctx_obj, cb;
346
 
    
 
354
 
347
355
    Check_Type(ary, T_ARRAY);
348
356
    ssl_obj = rb_ary_entry(ary, 0);
349
357
 
390
398
ossl_call_session_remove_cb(VALUE ary)
391
399
{
392
400
    VALUE sslctx_obj, cb;
393
 
    
 
401
 
394
402
    Check_Type(ary, T_ARRAY);
395
403
    sslctx_obj = rb_ary_entry(ary, 0);
396
404
 
446
454
    return i;
447
455
}
448
456
 
 
457
static VALUE ossl_sslctx_setup(VALUE self);
 
458
 
 
459
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
 
460
static VALUE
 
461
ossl_call_servername_cb(VALUE ary)
 
462
{
 
463
    VALUE ssl_obj, sslctx_obj, cb, ret_obj;
 
464
 
 
465
    Check_Type(ary, T_ARRAY);
 
466
    ssl_obj = rb_ary_entry(ary, 0);
 
467
 
 
468
    sslctx_obj = rb_iv_get(ssl_obj, "@context");
 
469
    if (NIL_P(sslctx_obj)) return Qnil;
 
470
    cb = rb_iv_get(sslctx_obj, "@servername_cb");
 
471
    if (NIL_P(cb)) return Qnil;
 
472
 
 
473
    ret_obj = rb_funcall(cb, rb_intern("call"), 1, ary);
 
474
    if (rb_obj_is_kind_of(ret_obj, cSSLContext)) {
 
475
        SSL *ssl;
 
476
        SSL_CTX *ctx2;
 
477
 
 
478
        ossl_sslctx_setup(ret_obj);
 
479
        Data_Get_Struct(ssl_obj, SSL, ssl);
 
480
        Data_Get_Struct(ret_obj, SSL_CTX, ctx2);
 
481
        SSL_set_SSL_CTX(ssl, ctx2);
 
482
    } else if (!NIL_P(ret_obj)) {
 
483
            rb_raise(rb_eArgError, "servername_cb must return an OpenSSL::SSL::SSLContext object or nil");
 
484
    }
 
485
 
 
486
    return ret_obj;
 
487
}
 
488
 
 
489
static int
 
490
ssl_servername_cb(SSL *ssl, int *ad, void *arg)
 
491
{
 
492
    VALUE ary, ssl_obj, ret_obj;
 
493
    void *ptr;
 
494
    int state = 0;
 
495
    const char *servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
 
496
 
 
497
    if (!servername)
 
498
        return SSL_TLSEXT_ERR_OK;
 
499
 
 
500
    if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
 
501
        return SSL_TLSEXT_ERR_ALERT_FATAL;
 
502
    ssl_obj = (VALUE)ptr;
 
503
    ary = rb_ary_new2(2);
 
504
    rb_ary_push(ary, ssl_obj);
 
505
    rb_ary_push(ary, rb_str_new2(servername));
 
506
 
 
507
    ret_obj = rb_protect((VALUE(*)_((VALUE)))ossl_call_servername_cb, ary, &state);
 
508
    if (state) {
 
509
        rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
 
510
        return SSL_TLSEXT_ERR_ALERT_FATAL;
 
511
    }
 
512
 
 
513
    return SSL_TLSEXT_ERR_OK;
 
514
}
 
515
#endif
 
516
 
449
517
/*
450
518
 * call-seq:
451
519
 *    ctx.setup => Qtrue # first time
581
649
        SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb);
582
650
        OSSL_Debug("SSL SESSION remove callback added");
583
651
    }
 
652
 
 
653
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
 
654
    val = rb_iv_get(self, "@servername_cb");
 
655
    if (!NIL_P(val)) {
 
656
        SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb);
 
657
        OSSL_Debug("SSL TLSEXT servername callback added");
 
658
    }
 
659
#endif
 
660
 
584
661
    return Qtrue;
585
662
}
586
663
 
828
905
        rb_raise(rb_eArgError, "arg must be Time or nil");
829
906
    }
830
907
 
831
 
    SSL_CTX_flush_sessions(ctx, tm);
 
908
    SSL_CTX_flush_sessions(ctx, (long)tm);
832
909
 
833
910
    return self;
834
911
}
886
963
    ossl_ssl_set_ctx(self, ctx);
887
964
    ossl_ssl_set_sync_close(self, Qfalse);
888
965
    ossl_sslctx_setup(ctx);
 
966
 
 
967
    rb_iv_set(self, "@hostname", Qnil);
 
968
 
889
969
    rb_call_super(0, 0);
890
970
 
891
971
    return self;
901
981
 
902
982
    Data_Get_Struct(self, SSL, ssl);
903
983
    if(!ssl){
 
984
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
 
985
        VALUE hostname = rb_iv_get(self, "@hostname");
 
986
#endif
 
987
 
904
988
        v_ctx = ossl_ssl_get_ctx(self);
905
989
        Data_Get_Struct(v_ctx, SSL_CTX, ctx);
906
990
 
910
994
        }
911
995
        DATA_PTR(self) = ssl;
912
996
 
 
997
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
 
998
        if (!NIL_P(hostname)) {
 
999
           if (SSL_set_tlsext_host_name(ssl, StringValuePtr(hostname)) != 1)
 
1000
               ossl_raise(eSSLError, "SSL_set_tlsext_host_name:");
 
1001
        }
 
1002
#endif
913
1003
        io = ossl_ssl_get_io(self);
914
1004
        GetOpenFile(io, fptr);
915
1005
        rb_io_check_readable(fptr);
933
1023
#define ssl_get_error(ssl, ret) SSL_get_error(ssl, ret)
934
1024
#endif
935
1025
 
 
1026
static void
 
1027
write_would_block(int nonblock)
 
1028
{
 
1029
    if (nonblock) {
 
1030
        VALUE exc = ossl_exc_new(eSSLError, "write would block");
 
1031
        rb_extend_object(exc, rb_mWaitWritable);
 
1032
        rb_exc_raise(exc);
 
1033
    }
 
1034
}
 
1035
 
 
1036
static void
 
1037
read_would_block(int nonblock)
 
1038
{
 
1039
    if (nonblock) {
 
1040
        VALUE exc = ossl_exc_new(eSSLError, "read would block");
 
1041
        rb_extend_object(exc, rb_mWaitReadable);
 
1042
        rb_exc_raise(exc);
 
1043
    }
 
1044
}
 
1045
 
936
1046
static VALUE
937
 
ossl_start_ssl(VALUE self, int (*func)(), const char *funcname)
 
1047
ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, int nonblock)
938
1048
{
939
1049
    SSL *ssl;
940
1050
    rb_io_t *fptr;
946
1056
    Data_Get_Struct(self, SSL, ssl);
947
1057
    GetOpenFile(ossl_ssl_get_io(self), fptr);
948
1058
    for(;;){
949
 
        if((ret = func(ssl)) > 0) break;
 
1059
        ret = func(ssl);
 
1060
 
 
1061
        cb_state = rb_ivar_get(self, ID_callback_state);
 
1062
        if (!NIL_P(cb_state))
 
1063
            rb_jump_tag(NUM2INT(cb_state));
 
1064
 
 
1065
        if (ret > 0)
 
1066
            break;
 
1067
 
950
1068
        switch((ret2 = ssl_get_error(ssl, ret))){
951
1069
        case SSL_ERROR_WANT_WRITE:
 
1070
            write_would_block(nonblock);
952
1071
            rb_io_wait_writable(FPTR_TO_FD(fptr));
953
1072
            continue;
954
1073
        case SSL_ERROR_WANT_READ:
 
1074
            read_would_block(nonblock);
955
1075
            rb_io_wait_readable(FPTR_TO_FD(fptr));
956
1076
            continue;
957
1077
        case SSL_ERROR_SYSCALL:
962
1082
        }
963
1083
    }
964
1084
 
965
 
    cb_state = rb_ivar_get(self, ID_callback_state);
966
 
    if (!NIL_P(cb_state))
967
 
        rb_jump_tag(NUM2INT(cb_state));
968
 
 
969
1085
    return self;
970
1086
}
971
1087
 
977
1093
ossl_ssl_connect(VALUE self)
978
1094
{
979
1095
    ossl_ssl_setup(self);
980
 
    return ossl_start_ssl(self, SSL_connect, "SSL_connect");
 
1096
    return ossl_start_ssl(self, SSL_connect, "SSL_connect", 0);
 
1097
}
 
1098
 
 
1099
/*
 
1100
 * call-seq:
 
1101
 *    ssl.connect_nonblock => self
 
1102
 *
 
1103
 * initiate the TLS/SSL handshake as a client in non-blocking manner.
 
1104
 *
 
1105
 *   # emulates blocking connect
 
1106
 *   begin
 
1107
 *     ssl.connect_nonblock
 
1108
 *   rescue IO::WaitReadable
 
1109
 *     IO.select([s2])
 
1110
 *     retry
 
1111
 *   rescue IO::WaitWritable
 
1112
 *     IO.select(nil, [s2])
 
1113
 *     retry
 
1114
 *   end
 
1115
 *
 
1116
 */
 
1117
static VALUE
 
1118
ossl_ssl_connect_nonblock(VALUE self)
 
1119
{
 
1120
    ossl_ssl_setup(self);
 
1121
    return ossl_start_ssl(self, SSL_connect, "SSL_connect", 1);
981
1122
}
982
1123
 
983
1124
/*
988
1129
ossl_ssl_accept(VALUE self)
989
1130
{
990
1131
    ossl_ssl_setup(self);
991
 
    return ossl_start_ssl(self, SSL_accept, "SSL_accept");
 
1132
    return ossl_start_ssl(self, SSL_accept, "SSL_accept", 0);
992
1133
}
993
1134
 
994
1135
/*
995
1136
 * call-seq:
996
 
 *    ssl.sysread(length) => string
997
 
 *    ssl.sysread(length, buffer) => buffer
998
 
 *
999
 
 * === Parameters
1000
 
 * * +length+ is a positive integer.
1001
 
 * * +buffer+ is a string used to store the result.
 
1137
 *    ssl.accept_nonblock => self
 
1138
 *
 
1139
 * initiate the TLS/SSL handshake as a server in non-blocking manner.
 
1140
 *
 
1141
 *   # emulates blocking accept
 
1142
 *   begin
 
1143
 *     ssl.accept_nonblock
 
1144
 *   rescue IO::WaitReadable
 
1145
 *     IO.select([s2])
 
1146
 *     retry
 
1147
 *   rescue IO::WaitWritable
 
1148
 *     IO.select(nil, [s2])
 
1149
 *     retry
 
1150
 *   end
 
1151
 *
1002
1152
 */
1003
1153
static VALUE
1004
 
ossl_ssl_read(int argc, VALUE *argv, VALUE self)
 
1154
ossl_ssl_accept_nonblock(VALUE self)
 
1155
{
 
1156
    ossl_ssl_setup(self);
 
1157
    return ossl_start_ssl(self, SSL_accept, "SSL_accept", 1);
 
1158
}
 
1159
 
 
1160
static VALUE
 
1161
ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
1005
1162
{
1006
1163
    SSL *ssl;
1007
1164
    int ilen, nread = 0;
1021
1178
    Data_Get_Struct(self, SSL, ssl);
1022
1179
    GetOpenFile(ossl_ssl_get_io(self), fptr);
1023
1180
    if (ssl) {
1024
 
        if(SSL_pending(ssl) <= 0)
 
1181
        if(!nonblock && SSL_pending(ssl) <= 0)
1025
1182
            rb_thread_wait_fd(FPTR_TO_FD(fptr));
1026
1183
        for (;;){
1027
1184
            nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
1031
1188
            case SSL_ERROR_ZERO_RETURN:
1032
1189
                rb_eof_error();
1033
1190
            case SSL_ERROR_WANT_WRITE:
 
1191
                write_would_block(nonblock);
1034
1192
                rb_io_wait_writable(FPTR_TO_FD(fptr));
1035
1193
                continue;
1036
1194
            case SSL_ERROR_WANT_READ:
 
1195
                read_would_block(nonblock);
1037
1196
                rb_io_wait_readable(FPTR_TO_FD(fptr));
1038
1197
                continue;
1039
1198
            case SSL_ERROR_SYSCALL:
1045
1204
        }
1046
1205
    }
1047
1206
    else {
1048
 
        ID id_sysread = rb_intern("sysread");
 
1207
        ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread");
1049
1208
        rb_warning("SSL session is not started yet.");
1050
 
        return rb_funcall(ossl_ssl_get_io(self), id_sysread, 2, len, str);
 
1209
        return rb_funcall(ossl_ssl_get_io(self), meth, 2, len, str);
1051
1210
    }
1052
1211
 
1053
1212
  end:
1057
1216
    return str;
1058
1217
}
1059
1218
 
1060
 
/*
1061
 
 * call-seq:
1062
 
 *    ssl.syswrite(string) => integer
1063
 
 */
1064
 
static VALUE
1065
 
ossl_ssl_write(VALUE self, VALUE str)
 
1219
 
 
1220
/*
 
1221
 * call-seq:
 
1222
 *    ssl.sysread(length) => string
 
1223
 *    ssl.sysread(length, buffer) => buffer
 
1224
 *
 
1225
 * === Parameters
 
1226
 * * +length+ is a positive integer.
 
1227
 * * +buffer+ is a string used to store the result.
 
1228
 */
 
1229
static VALUE
 
1230
ossl_ssl_read(int argc, VALUE *argv, VALUE self)
 
1231
{
 
1232
    return ossl_ssl_read_internal(argc, argv, self, 0);
 
1233
}
 
1234
 
 
1235
/*
 
1236
 * call-seq:
 
1237
 *    ssl.sysread_nonblock(length) => string
 
1238
 *    ssl.sysread_nonblock(length, buffer) => buffer
 
1239
 *
 
1240
 * === Parameters
 
1241
 * * +length+ is a positive integer.
 
1242
 * * +buffer+ is a string used to store the result.
 
1243
 */
 
1244
static VALUE
 
1245
ossl_ssl_read_nonblock(int argc, VALUE *argv, VALUE self)
 
1246
{
 
1247
    return ossl_ssl_read_internal(argc, argv, self, 1);
 
1248
}
 
1249
 
 
1250
static VALUE
 
1251
ossl_ssl_write_internal(VALUE self, VALUE str, int nonblock)
1066
1252
{
1067
1253
    SSL *ssl;
1068
1254
    int nwrite = 0;
1079
1265
            case SSL_ERROR_NONE:
1080
1266
                goto end;
1081
1267
            case SSL_ERROR_WANT_WRITE:
 
1268
                write_would_block(nonblock);
1082
1269
                rb_io_wait_writable(FPTR_TO_FD(fptr));
1083
1270
                continue;
1084
1271
            case SSL_ERROR_WANT_READ:
 
1272
                read_would_block(nonblock);
1085
1273
                rb_io_wait_readable(FPTR_TO_FD(fptr));
1086
1274
                continue;
1087
1275
            case SSL_ERROR_SYSCALL:
1103
1291
 
1104
1292
/*
1105
1293
 * call-seq:
 
1294
 *    ssl.syswrite(string) => integer
 
1295
 */
 
1296
static VALUE
 
1297
ossl_ssl_write(VALUE self, VALUE str)
 
1298
{
 
1299
    return ossl_ssl_write_internal(self, str, 0);
 
1300
}
 
1301
 
 
1302
/*
 
1303
 * call-seq:
 
1304
 *    ssl.syswrite_nonblock(string) => integer
 
1305
 */
 
1306
static VALUE
 
1307
ossl_ssl_write_nonblock(VALUE self, VALUE str)
 
1308
{
 
1309
    return ossl_ssl_write_internal(self, str, 1);
 
1310
}
 
1311
 
 
1312
/*
 
1313
 * call-seq:
1106
1314
 *    ssl.sysclose => nil
1107
1315
 */
1108
1316
static VALUE
1195
1403
    }
1196
1404
    chain = SSL_get_peer_cert_chain(ssl);
1197
1405
    if(!chain) return Qnil;
1198
 
    num = sk_num(chain);
 
1406
    num = sk_X509_num(chain);
1199
1407
    ary = rb_ary_new2(num);
1200
1408
    for (i = 0; i < num; i++){
1201
 
        cert = (X509*)sk_value(chain, i);
 
1409
        cert = sk_X509_value(chain, i);
1202
1410
        rb_ary_push(ary, ossl_x509_new(cert));
1203
1411
    }
1204
1412
 
1220
1428
        rb_warning("SSL session is not started yet.");
1221
1429
        return Qnil;
1222
1430
    }
1223
 
    cipher = SSL_get_current_cipher(ssl);
 
1431
    cipher = (SSL_CIPHER *)SSL_get_current_cipher(ssl);
1224
1432
 
1225
1433
    return ossl_ssl_cipher_to_ary(cipher);
1226
1434
}
1369
1577
    for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
1370
1578
        rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
1371
1579
    rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
 
1580
    rb_define_alias(cSSLContext, "ssl_timeout=", "timeout=");
1372
1581
    rb_define_method(cSSLContext, "initialize",  ossl_sslctx_initialize, -1);
1373
1582
    rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);
1374
1583
    rb_define_method(cSSLContext, "ciphers",     ossl_sslctx_get_ciphers, 0);
1376
1585
 
1377
1586
    rb_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0);
1378
1587
 
1379
 
    
 
1588
 
1380
1589
    rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF));
1381
1590
    rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */
1382
1591
    rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER));
1417
1626
    rb_define_alias(cSSLSocket, "to_io", "io");
1418
1627
    rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
1419
1628
    rb_define_method(cSSLSocket, "connect",    ossl_ssl_connect, 0);
 
1629
    rb_define_method(cSSLSocket, "connect_nonblock",    ossl_ssl_connect_nonblock, 0);
1420
1630
    rb_define_method(cSSLSocket, "accept",     ossl_ssl_accept, 0);
 
1631
    rb_define_method(cSSLSocket, "accept_nonblock",     ossl_ssl_accept_nonblock, 0);
1421
1632
    rb_define_method(cSSLSocket, "sysread",    ossl_ssl_read, -1);
 
1633
    rb_define_private_method(cSSLSocket, "sysread_nonblock",    ossl_ssl_read_nonblock, -1);
1422
1634
    rb_define_method(cSSLSocket, "syswrite",   ossl_ssl_write, 1);
 
1635
    rb_define_private_method(cSSLSocket, "syswrite_nonblock",    ossl_ssl_write_nonblock, 1);
1423
1636
    rb_define_method(cSSLSocket, "sysclose",   ossl_ssl_close, 0);
1424
1637
    rb_define_method(cSSLSocket, "cert",       ossl_ssl_get_cert, 0);
1425
1638
    rb_define_method(cSSLSocket, "peer_cert",  ossl_ssl_get_peer_cert, 0);