зеркало из https://github.com/github/ruby.git
* ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move
OpenSSL::SSL::SSLContext#initialize implementation to pure Ruby. * ext/openssl/ossl_ssl.c (ossl_sslctx_initialize): ditto * ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e02186f526
Коммит
c8884ebfe4
|
@ -1,3 +1,12 @@
|
||||||
|
Sun Jul 26 03:42:19 2015 Aaron Patterson <tenderlove@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move
|
||||||
|
OpenSSL::SSL::SSLContext#initialize implementation to pure Ruby.
|
||||||
|
|
||||||
|
* ext/openssl/ossl_ssl.c (ossl_sslctx_initialize): ditto
|
||||||
|
|
||||||
|
* ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto
|
||||||
|
|
||||||
Sat Jul 25 21:03:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Jul 25 21:03:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* random.c (fill_random_bytes_syscall): get rid of blocking when
|
* random.c (fill_random_bytes_syscall): get rid of blocking when
|
||||||
|
|
|
@ -74,6 +74,26 @@ module OpenSSL
|
||||||
DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
|
DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
INIT_VARS = ["cert", "key", "client_ca", "ca_file", "ca_path",
|
||||||
|
"timeout", "verify_mode", "verify_depth", "renegotiation_cb",
|
||||||
|
"verify_callback", "options", "cert_store", "extra_chain_cert",
|
||||||
|
"client_cert_cb", "tmp_dh_callback", "session_id_context",
|
||||||
|
"session_get_cb", "session_new_cb", "session_remove_cb",
|
||||||
|
"tmp_ecdh_callback", "servername_cb", "npn_protocols",
|
||||||
|
"npn_select_cb"].map { |x| "@#{x}" }
|
||||||
|
|
||||||
|
# call-seq:
|
||||||
|
# SSLContext.new => ctx
|
||||||
|
# SSLContext.new(:TLSv1) => ctx
|
||||||
|
# SSLContext.new("SSLv23_client") => ctx
|
||||||
|
#
|
||||||
|
# You can get a list of valid methods with OpenSSL::SSL::SSLContext::METHODS
|
||||||
|
def initialize(version = nil)
|
||||||
|
INIT_VARS.each { |v| instance_variable_set v, nil }
|
||||||
|
return unless version
|
||||||
|
self.ssl_version = version
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Sets the parameters for this SSL context to the values in +params+.
|
# Sets the parameters for this SSL context to the values in +params+.
|
||||||
# The keys in +params+ must be assignment methods on SSLContext.
|
# The keys in +params+ must be assignment methods on SSLContext.
|
||||||
|
|
|
@ -69,22 +69,6 @@ static VALUE eSSLErrorWaitWritable;
|
||||||
#define ossl_sslctx_get_tmp_dh_cb(o) rb_iv_get((o),"@tmp_dh_callback")
|
#define ossl_sslctx_get_tmp_dh_cb(o) rb_iv_get((o),"@tmp_dh_callback")
|
||||||
#define ossl_sslctx_get_sess_id_ctx(o) rb_iv_get((o),"@session_id_context")
|
#define ossl_sslctx_get_sess_id_ctx(o) rb_iv_get((o),"@session_id_context")
|
||||||
|
|
||||||
static const char *ossl_sslctx_attrs[] = {
|
|
||||||
"cert", "key", "client_ca", "ca_file", "ca_path",
|
|
||||||
"timeout", "verify_mode", "verify_depth", "renegotiation_cb",
|
|
||||||
"verify_callback", "options", "cert_store", "extra_chain_cert",
|
|
||||||
"client_cert_cb", "tmp_dh_callback", "session_id_context",
|
|
||||||
"session_get_cb", "session_new_cb", "session_remove_cb",
|
|
||||||
"tmp_ecdh_callback",
|
|
||||||
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
|
|
||||||
"servername_cb",
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_OPENSSL_NPN_NEGOTIATED
|
|
||||||
"npn_protocols",
|
|
||||||
"npn_select_cb",
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ossl_ssl_get_io(o) rb_iv_get((o),"@io")
|
#define ossl_ssl_get_io(o) rb_iv_get((o),"@io")
|
||||||
#define ossl_ssl_get_ctx(o) rb_iv_get((o),"@context")
|
#define ossl_ssl_get_ctx(o) rb_iv_get((o),"@context")
|
||||||
#define ossl_ssl_get_sync_close(o) rb_iv_get((o),"@sync_close")
|
#define ossl_ssl_get_sync_close(o) rb_iv_get((o),"@sync_close")
|
||||||
|
@ -232,33 +216,6 @@ ossl_sslctx_set_ssl_version(VALUE self, VALUE ssl_method)
|
||||||
return ssl_method;
|
return ssl_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* SSLContext.new => ctx
|
|
||||||
* SSLContext.new(:TLSv1) => ctx
|
|
||||||
* SSLContext.new("SSLv23_client") => ctx
|
|
||||||
*
|
|
||||||
* You can get a list of valid methods with OpenSSL::SSL::SSLContext::METHODS
|
|
||||||
*/
|
|
||||||
static VALUE
|
|
||||||
ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
|
|
||||||
{
|
|
||||||
VALUE ssl_method;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
|
|
||||||
char buf[32];
|
|
||||||
snprintf(buf, sizeof(buf), "@%s", ossl_sslctx_attrs[i]);
|
|
||||||
rb_iv_set(self, buf, Qnil);
|
|
||||||
}
|
|
||||||
if (rb_scan_args(argc, argv, "01", &ssl_method) == 0){
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
ossl_sslctx_set_ssl_version(self, ssl_method);
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
ossl_call_client_cert_cb(VALUE obj)
|
ossl_call_client_cert_cb(VALUE obj)
|
||||||
{
|
{
|
||||||
|
@ -2315,7 +2272,6 @@ Init_ossl_ssl(void)
|
||||||
|
|
||||||
rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
|
rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
|
||||||
rb_define_alias(cSSLContext, "ssl_timeout=", "timeout=");
|
rb_define_alias(cSSLContext, "ssl_timeout=", "timeout=");
|
||||||
rb_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1);
|
|
||||||
rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);
|
rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);
|
||||||
rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);
|
rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);
|
||||||
rb_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1);
|
rb_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче