2 * librb: a library used by ircd-ratbox and other things
3 * openssl.c: openssl related code
5 * Copyright (C) 2007-2008 ircd-ratbox development team
6 * Copyright (C) 2007-2008 Aaron Sethman <androsyn@ratbox.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
25 #include <librb_config.h>
30 #include <commio-int.h>
31 #include <commio-ssl.h>
32 #include <openssl/ssl.h>
33 #include <openssl/dh.h>
34 #include <openssl/err.h>
35 #include <openssl/evp.h>
36 #include <openssl/rand.h>
37 #include <openssl/opensslv.h>
40 * This is a mess but what can you do when the library authors
41 * refuse to play ball with established conventions?
43 #if defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER >= 0x20020002L)
44 # define LRB_HAVE_TLS_METHOD_API 1
46 # if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100000L)
47 # define LRB_HAVE_TLS_METHOD_API 1
52 * Use SSL_CTX_set_ecdh_auto() in OpenSSL 1.0.2 only
53 * Use SSL_CTX_set1_curves_list() in OpenSSL 1.0.2 and above
54 * TODO: Merge this into the block above if LibreSSL implements them
56 #if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10002000L)
57 # define LRB_HAVE_TLS_SET_CURVES 1
58 # if (OPENSSL_VERSION_NUMBER < 0x10100000L)
59 # define LRB_HAVE_TLS_ECDH_AUTO 1
63 static SSL_CTX
*ssl_server_ctx
= NULL
;
64 static SSL_CTX
*ssl_client_ctx
= NULL
;
65 static int librb_index
= -1;
70 unsigned long t_err
, err
= 0;
71 err
= ERR_get_error();
75 while((t_err
= ERR_get_error()) > 0)
82 rb_ssl_shutdown(rb_fde_t
*F
)
85 if(F
== NULL
|| F
->ssl
== NULL
)
87 SSL_set_shutdown((SSL
*) F
->ssl
, SSL_RECEIVED_SHUTDOWN
);
89 for(i
= 0; i
< 4; i
++)
91 if(SSL_shutdown((SSL
*) F
->ssl
))
95 SSL_free((SSL
*) F
->ssl
);
99 rb_ssl_handshake_count(rb_fde_t
*F
)
101 return F
->handshake_count
;
105 rb_ssl_clear_handshake_count(rb_fde_t
*F
)
107 F
->handshake_count
= 0;
111 rb_ssl_timeout(rb_fde_t
*F
, void *notused
)
113 lrb_assert(F
->accept
!= NULL
);
114 F
->accept
->callback(F
, RB_ERR_TIMEOUT
, NULL
, 0, F
->accept
->data
);
119 rb_ssl_info_callback(SSL
* ssl
, int where
, int ret
)
121 if(where
& SSL_CB_HANDSHAKE_START
)
123 rb_fde_t
*F
= SSL_get_ex_data(ssl
, librb_index
);
126 F
->handshake_count
++;
131 rb_setup_ssl_cb(rb_fde_t
*F
)
133 SSL_set_ex_data(F
->ssl
, librb_index
, (char *)F
);
134 SSL_set_info_callback((SSL
*) F
->ssl
, (void (*)(const SSL
*,int,int))rb_ssl_info_callback
);
138 rb_ssl_tryaccept(rb_fde_t
*F
, void *data
)
141 lrb_assert(F
->accept
!= NULL
);
143 struct acceptdata
*ad
;
145 if(!SSL_is_init_finished((SSL
*) F
->ssl
))
147 if((ssl_err
= SSL_accept((SSL
*) F
->ssl
)) <= 0)
149 switch (ssl_err
= SSL_get_error((SSL
*) F
->ssl
, ssl_err
))
151 case SSL_ERROR_WANT_READ
:
152 case SSL_ERROR_WANT_WRITE
:
153 if(ssl_err
== SSL_ERROR_WANT_WRITE
)
154 flags
= RB_SELECT_WRITE
;
156 flags
= RB_SELECT_READ
;
157 F
->ssl_errno
= get_last_err();
158 rb_setselect(F
, flags
, rb_ssl_tryaccept
, NULL
);
160 case SSL_ERROR_SYSCALL
:
161 F
->accept
->callback(F
, RB_ERROR
, NULL
, 0, F
->accept
->data
);
164 F
->ssl_errno
= get_last_err();
165 F
->accept
->callback(F
, RB_ERROR_SSL
, NULL
, 0, F
->accept
->data
);
171 rb_settimeout(F
, 0, NULL
, NULL
);
172 rb_setselect(F
, RB_SELECT_READ
| RB_SELECT_WRITE
, NULL
, NULL
);
176 ad
->callback(F
, RB_OK
, (struct sockaddr
*)&ad
->S
, ad
->addrlen
, ad
->data
);
183 rb_ssl_accept_common(rb_fde_t
*new_F
)
186 if((ssl_err
= SSL_accept((SSL
*) new_F
->ssl
)) <= 0)
188 switch (ssl_err
= SSL_get_error((SSL
*) new_F
->ssl
, ssl_err
))
190 case SSL_ERROR_SYSCALL
:
191 if(rb_ignore_errno(errno
))
192 case SSL_ERROR_WANT_READ
:
193 case SSL_ERROR_WANT_WRITE
:
195 new_F
->ssl_errno
= get_last_err();
196 rb_setselect(new_F
, RB_SELECT_READ
| RB_SELECT_WRITE
,
197 rb_ssl_tryaccept
, NULL
);
201 new_F
->ssl_errno
= get_last_err();
202 new_F
->accept
->callback(new_F
, RB_ERROR_SSL
, NULL
, 0, new_F
->accept
->data
);
208 rb_ssl_tryaccept(new_F
, NULL
);
213 rb_ssl_start_accepted(rb_fde_t
*new_F
, ACCB
* cb
, void *data
, int timeout
)
215 new_F
->type
|= RB_FD_SSL
;
216 new_F
->ssl
= SSL_new(ssl_server_ctx
);
217 new_F
->accept
= rb_malloc(sizeof(struct acceptdata
));
219 new_F
->accept
->callback
= cb
;
220 new_F
->accept
->data
= data
;
221 rb_settimeout(new_F
, timeout
, rb_ssl_timeout
, NULL
);
223 new_F
->accept
->addrlen
= 0;
224 SSL_set_fd((SSL
*) new_F
->ssl
, rb_get_fd(new_F
));
225 rb_setup_ssl_cb(new_F
);
226 rb_ssl_accept_common(new_F
);
233 rb_ssl_accept_setup(rb_fde_t
*F
, rb_fde_t
*new_F
, struct sockaddr
*st
, int addrlen
)
235 new_F
->type
|= RB_FD_SSL
;
236 new_F
->ssl
= SSL_new(ssl_server_ctx
);
237 new_F
->accept
= rb_malloc(sizeof(struct acceptdata
));
239 new_F
->accept
->callback
= F
->accept
->callback
;
240 new_F
->accept
->data
= F
->accept
->data
;
241 rb_settimeout(new_F
, 10, rb_ssl_timeout
, NULL
);
242 memcpy(&new_F
->accept
->S
, st
, addrlen
);
243 new_F
->accept
->addrlen
= addrlen
;
245 SSL_set_fd((SSL
*) new_F
->ssl
, rb_get_fd(new_F
));
246 rb_setup_ssl_cb(new_F
);
247 rb_ssl_accept_common(new_F
);
251 rb_ssl_read_or_write(int r_or_w
, rb_fde_t
*F
, void *rbuf
, const void *wbuf
, size_t count
)
258 ret
= (ssize_t
) SSL_read(ssl
, rbuf
, (int)count
);
260 ret
= (ssize_t
) SSL_write(ssl
, wbuf
, (int)count
);
264 switch (SSL_get_error(ssl
, ret
))
266 case SSL_ERROR_WANT_READ
:
268 return RB_RW_SSL_NEED_READ
;
269 case SSL_ERROR_WANT_WRITE
:
271 return RB_RW_SSL_NEED_WRITE
;
272 case SSL_ERROR_ZERO_RETURN
:
274 case SSL_ERROR_SYSCALL
:
275 err
= get_last_err();
279 return RB_RW_IO_ERROR
;
283 err
= get_last_err();
289 errno
= EIO
; /* not great but... */
290 return RB_RW_SSL_ERROR
;
292 return RB_RW_IO_ERROR
;
298 rb_ssl_read(rb_fde_t
*F
, void *buf
, size_t count
)
300 return rb_ssl_read_or_write(0, F
, buf
, NULL
, count
);
304 rb_ssl_write(rb_fde_t
*F
, const void *buf
, size_t count
)
306 return rb_ssl_read_or_write(1, F
, NULL
, buf
, count
);
310 verify_accept_all_cb(int preverify_ok
, X509_STORE_CTX
*x509_ctx
)
316 get_ssl_error(unsigned long err
)
318 static char buf
[512];
320 ERR_error_string_n(err
, buf
, sizeof buf
);
327 char librb_data
[] = "librb data";
329 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
331 * OpenSSL 1.1.0 and above automatically initialises itself with sane defaults
334 SSL_load_error_strings();
337 librb_index
= SSL_get_ex_new_index(0, librb_data
, NULL
, NULL
, NULL
);
343 rb_setup_ssl_server(const char *certfile
, const char *keyfile
, const char *dhfile
, const char *cipher_list
)
345 const char librb_ciphers
[] = "kEECDH+HIGH:kEDH+HIGH:HIGH:!aNULL";
347 #ifdef LRB_HAVE_TLS_SET_CURVES
348 const char librb_curves
[] = "P-521:P-384:P-256";
353 rb_lib_log("rb_setup_ssl_server: No certificate file");
360 if(cipher_list
== NULL
)
361 cipher_list
= librb_ciphers
;
364 SSL_CTX_free(ssl_server_ctx
);
367 SSL_CTX_free(ssl_client_ctx
);
369 #ifdef LRB_HAVE_TLS_METHOD_API
370 ssl_server_ctx
= SSL_CTX_new(TLS_server_method());
371 ssl_client_ctx
= SSL_CTX_new(TLS_client_method());
373 ssl_server_ctx
= SSL_CTX_new(SSLv23_server_method());
374 ssl_client_ctx
= SSL_CTX_new(SSLv23_client_method());
377 if(ssl_server_ctx
== NULL
)
379 rb_lib_log("rb_init_openssl: Unable to initialize OpenSSL server context: %s",
380 get_ssl_error(ERR_get_error()));
384 if(ssl_client_ctx
== NULL
)
386 rb_lib_log("rb_init_openssl: Unable to initialize OpenSSL client context: %s",
387 get_ssl_error(ERR_get_error()));
391 #ifndef LRB_HAVE_TLS_METHOD_API
392 SSL_CTX_set_options(ssl_server_ctx
, SSL_OP_NO_SSLv2
| SSL_OP_NO_SSLv3
);
393 SSL_CTX_set_options(ssl_client_ctx
, SSL_OP_NO_SSLv2
| SSL_OP_NO_SSLv3
);
396 #ifdef SSL_OP_SINGLE_DH_USE
397 SSL_CTX_set_options(ssl_server_ctx
, SSL_OP_SINGLE_DH_USE
);
400 #ifdef SSL_OP_SINGLE_ECDH_USE
401 SSL_CTX_set_options(ssl_server_ctx
, SSL_OP_SINGLE_ECDH_USE
);
404 #ifdef SSL_OP_NO_TICKET
405 SSL_CTX_set_options(ssl_server_ctx
, SSL_OP_NO_TICKET
);
406 SSL_CTX_set_options(ssl_client_ctx
, SSL_OP_NO_TICKET
);
409 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
410 SSL_CTX_set_options(ssl_server_ctx
, SSL_OP_CIPHER_SERVER_PREFERENCE
);
413 SSL_CTX_set_verify(ssl_server_ctx
, SSL_VERIFY_PEER
| SSL_VERIFY_CLIENT_ONCE
, verify_accept_all_cb
);
414 SSL_CTX_set_session_cache_mode(ssl_server_ctx
, SSL_SESS_CACHE_OFF
);
416 #ifdef LRB_HAVE_TLS_SET_CURVES
417 SSL_CTX_set1_curves_list(ssl_server_ctx
, librb_curves
);
420 #ifdef LRB_HAVE_TLS_ECDH_AUTO
421 SSL_CTX_set_ecdh_auto(ssl_server_ctx
, 1);
425 * Set manual ECDHE curve on OpenSSL 1.0.0 & 1.0.1, but make sure it's actually available
427 #if (OPENSSL_VERSION_NUMBER >= 0x10000000L) && (OPENSSL_VERSION_NUMBER < 0x10002000L) && !defined(OPENSSL_NO_ECDH)
428 EC_KEY
*key
= EC_KEY_new_by_curve_name(NID_secp384r1
);
430 SSL_CTX_set_tmp_ecdh(ssl_server_ctx
, key
);
435 SSL_CTX_set_cipher_list(ssl_server_ctx
, cipher_list
);
436 SSL_CTX_set_cipher_list(ssl_client_ctx
, cipher_list
);
438 if(!SSL_CTX_use_certificate_chain_file(ssl_server_ctx
, certfile
) || !SSL_CTX_use_certificate_chain_file(ssl_client_ctx
, certfile
))
440 rb_lib_log("rb_setup_ssl_server: Error loading certificate file [%s]: %s", certfile
,
441 get_ssl_error(ERR_get_error()));
445 if(!SSL_CTX_use_PrivateKey_file(ssl_server_ctx
, keyfile
, SSL_FILETYPE_PEM
) || !SSL_CTX_use_PrivateKey_file(ssl_client_ctx
, keyfile
, SSL_FILETYPE_PEM
))
447 rb_lib_log("rb_setup_ssl_server: Error loading keyfile [%s]: %s", keyfile
,
448 get_ssl_error(ERR_get_error()));
454 /* DH parameters aren't necessary, but they are nice..if they didn't pass one..that is their problem */
455 BIO
*bio
= BIO_new_file(dhfile
, "r");
458 DH
*dh
= PEM_read_bio_DHparams(bio
, NULL
, NULL
, NULL
);
462 ("rb_setup_ssl_server: Error loading DH params file [%s]: %s",
463 dhfile
, get_ssl_error(ERR_get_error()));
468 SSL_CTX_set_tmp_dh(ssl_server_ctx
, dh
);
473 rb_lib_log("rb_setup_ssl_server: Error loading DH params file [%s]: %s",
474 dhfile
, get_ssl_error(ERR_get_error()));
482 rb_ssl_listen(rb_fde_t
*F
, int backlog
, int defer_accept
)
486 result
= rb_listen(F
, backlog
, defer_accept
);
487 F
->type
= RB_FD_SOCKET
| RB_FD_LISTEN
| RB_FD_SSL
;
500 rb_ssl_connect_realcb(rb_fde_t
*F
, int status
, struct ssl_connect
*sconn
)
502 F
->connect
->callback
= sconn
->callback
;
503 F
->connect
->data
= sconn
->data
;
505 rb_connect_callback(F
, status
);
509 rb_ssl_tryconn_timeout_cb(rb_fde_t
*F
, void *data
)
511 rb_ssl_connect_realcb(F
, RB_ERR_TIMEOUT
, data
);
515 rb_ssl_tryconn_cb(rb_fde_t
*F
, void *data
)
517 struct ssl_connect
*sconn
= data
;
519 if(!SSL_is_init_finished((SSL
*) F
->ssl
))
521 if((ssl_err
= SSL_connect((SSL
*) F
->ssl
)) <= 0)
523 switch (ssl_err
= SSL_get_error((SSL
*) F
->ssl
, ssl_err
))
525 case SSL_ERROR_SYSCALL
:
526 if(rb_ignore_errno(errno
))
527 case SSL_ERROR_WANT_READ
:
528 case SSL_ERROR_WANT_WRITE
:
530 F
->ssl_errno
= get_last_err();
531 rb_setselect(F
, RB_SELECT_READ
| RB_SELECT_WRITE
,
532 rb_ssl_tryconn_cb
, sconn
);
536 F
->ssl_errno
= get_last_err();
537 rb_ssl_connect_realcb(F
, RB_ERROR_SSL
, sconn
);
543 rb_ssl_connect_realcb(F
, RB_OK
, sconn
);
549 rb_ssl_tryconn(rb_fde_t
*F
, int status
, void *data
)
551 struct ssl_connect
*sconn
= data
;
555 rb_ssl_connect_realcb(F
, status
, sconn
);
559 F
->type
|= RB_FD_SSL
;
560 F
->ssl
= SSL_new(ssl_client_ctx
);
561 SSL_set_fd((SSL
*) F
->ssl
, F
->fd
);
563 rb_settimeout(F
, sconn
->timeout
, rb_ssl_tryconn_timeout_cb
, sconn
);
564 if((ssl_err
= SSL_connect((SSL
*) F
->ssl
)) <= 0)
566 switch (ssl_err
= SSL_get_error((SSL
*) F
->ssl
, ssl_err
))
568 case SSL_ERROR_SYSCALL
:
569 if(rb_ignore_errno(errno
))
570 case SSL_ERROR_WANT_READ
:
571 case SSL_ERROR_WANT_WRITE
:
573 F
->ssl_errno
= get_last_err();
574 rb_setselect(F
, RB_SELECT_READ
| RB_SELECT_WRITE
,
575 rb_ssl_tryconn_cb
, sconn
);
579 F
->ssl_errno
= get_last_err();
580 rb_ssl_connect_realcb(F
, RB_ERROR_SSL
, sconn
);
586 rb_ssl_connect_realcb(F
, RB_OK
, sconn
);
591 rb_connect_tcp_ssl(rb_fde_t
*F
, struct sockaddr
*dest
,
592 struct sockaddr
*clocal
, CNCB
* callback
, void *data
, int timeout
)
594 struct ssl_connect
*sconn
;
598 sconn
= rb_malloc(sizeof(struct ssl_connect
));
600 sconn
->callback
= callback
;
601 sconn
->timeout
= timeout
;
602 rb_connect_tcp(F
, dest
, clocal
, rb_ssl_tryconn
, sconn
, timeout
);
606 rb_ssl_start_connected(rb_fde_t
*F
, CNCB
* callback
, void *data
, int timeout
)
608 struct ssl_connect
*sconn
;
613 sconn
= rb_malloc(sizeof(struct ssl_connect
));
615 sconn
->callback
= callback
;
616 sconn
->timeout
= timeout
;
617 F
->connect
= rb_malloc(sizeof(struct conndata
));
618 F
->connect
->callback
= callback
;
619 F
->connect
->data
= data
;
620 F
->type
|= RB_FD_SSL
;
621 F
->ssl
= SSL_new(ssl_client_ctx
);
623 SSL_set_fd((SSL
*) F
->ssl
, F
->fd
);
625 rb_settimeout(F
, sconn
->timeout
, rb_ssl_tryconn_timeout_cb
, sconn
);
626 if((ssl_err
= SSL_connect((SSL
*) F
->ssl
)) <= 0)
628 switch (ssl_err
= SSL_get_error((SSL
*) F
->ssl
, ssl_err
))
630 case SSL_ERROR_SYSCALL
:
631 if(rb_ignore_errno(errno
))
632 case SSL_ERROR_WANT_READ
:
633 case SSL_ERROR_WANT_WRITE
:
635 F
->ssl_errno
= get_last_err();
636 rb_setselect(F
, RB_SELECT_READ
| RB_SELECT_WRITE
,
637 rb_ssl_tryconn_cb
, sconn
);
641 F
->ssl_errno
= get_last_err();
642 rb_ssl_connect_realcb(F
, RB_ERROR_SSL
, sconn
);
648 rb_ssl_connect_realcb(F
, RB_OK
, sconn
);
653 rb_init_prng(const char *path
, prng_seed_t seed_type
)
655 if(seed_type
== RB_PRNG_DEFAULT
)
660 return RAND_status();
663 return RAND_status();
668 if(RAND_load_file(path
, -1) == -1)
680 return RAND_status();
684 rb_get_random(void *buf
, size_t length
)
688 if((ret
= RAND_bytes(buf
, length
)) == 0)
690 /* remove the error from the queue */
697 rb_get_ssl_strerror(rb_fde_t
*F
)
699 return get_ssl_error(F
->ssl_errno
);
703 make_certfp(X509
*cert
, uint8_t certfp
[RB_SSL_CERTFP_LEN
], int method
)
712 case RB_SSL_CERTFP_METH_CERT_SHA1
:
713 it
= ASN1_ITEM_rptr(X509
);
716 len
= RB_SSL_CERTFP_LEN_SHA1
;
718 case RB_SSL_CERTFP_METH_CERT_SHA256
:
719 it
= ASN1_ITEM_rptr(X509
);
722 len
= RB_SSL_CERTFP_LEN_SHA256
;
724 case RB_SSL_CERTFP_METH_CERT_SHA512
:
725 it
= ASN1_ITEM_rptr(X509
);
728 len
= RB_SSL_CERTFP_LEN_SHA512
;
730 case RB_SSL_CERTFP_METH_SPKI_SHA256
:
731 it
= ASN1_ITEM_rptr(X509_PUBKEY
);
733 data
= X509_get_X509_PUBKEY(cert
);
734 len
= RB_SSL_CERTFP_LEN_SHA256
;
736 case RB_SSL_CERTFP_METH_SPKI_SHA512
:
737 it
= ASN1_ITEM_rptr(X509_PUBKEY
);
739 data
= X509_get_X509_PUBKEY(cert
);
740 len
= RB_SSL_CERTFP_LEN_SHA512
;
746 if (ASN1_item_digest(it
, evp
, data
, certfp
, &len
) != 1)
752 rb_get_ssl_certfp(rb_fde_t
*F
, uint8_t certfp
[RB_SSL_CERTFP_LEN
], int method
)
761 cert
= SSL_get_peer_certificate((SSL
*) F
->ssl
);
765 res
= SSL_get_verify_result((SSL
*) F
->ssl
);
769 case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
:
770 case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
:
771 case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
:
772 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
:
773 case X509_V_ERR_CERT_UNTRUSTED
:
774 len
= make_certfp(cert
, certfp
, method
);
776 default: /* to silence code inspectors */
785 rb_get_ssl_certfp_file(const char *filename
, uint8_t certfp
[RB_SSL_CERTFP_LEN
], int method
)
788 FILE *f
= fopen(filename
, "r");
793 cert
= PEM_read_X509(f
, NULL
, NULL
, NULL
);
797 unsigned int len
= make_certfp(cert
, certfp
, method
);
805 rb_supports_ssl(void)
811 rb_get_ssl_info(char *buf
, size_t len
)
813 #if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
814 if (OpenSSL_version_num() == OPENSSL_VERSION_NUMBER
)
815 snprintf(buf
, len
, "OpenSSL: 0x%lx, %s",
816 OPENSSL_VERSION_NUMBER
, OPENSSL_VERSION_TEXT
);
818 snprintf(buf
, len
, "OpenSSL: compiled (0x%lx, %s), library (0x%lx, %s)",
819 OPENSSL_VERSION_NUMBER
, OPENSSL_VERSION_TEXT
,
820 OpenSSL_version_num(), OpenSSL_version(OPENSSL_VERSION
));
822 if (SSLeay() == SSLEAY_VERSION_NUMBER
)
823 snprintf(buf
, len
, "OpenSSL: 0x%lx, %s",
824 SSLeay(), SSLeay_version(SSLEAY_VERSION
));
826 snprintf(buf
, len
, "OpenSSL: compiled (0x%lx, %s), library (0x%lx, %s)",
827 SSLEAY_VERSION_NUMBER
, "???",
828 SSLeay(), SSLeay_version(SSLEAY_VERSION
));
833 rb_ssl_get_cipher(rb_fde_t
*F
)
835 const SSL_CIPHER
*sslciph
;
837 if(F
== NULL
|| F
->ssl
== NULL
)
840 if((sslciph
= SSL_get_current_cipher(F
->ssl
)) == NULL
)
843 return SSL_CIPHER_get_name(sslciph
);
846 #endif /* HAVE_OPENSSL */