diff options
author | unknown <monty@mashka.mysql.fi> | 2002-11-21 15:56:48 +0200 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-11-21 15:56:48 +0200 |
commit | 33fc0d53b543032accea2476a4eed0522cead2bb (patch) | |
tree | d3df5d3fc1abf364dcbcc8eb2305a1cf62540192 /vio | |
parent | 2723dbdb5e2c60162ca464f65f68fdd13b7c9cef (diff) | |
parent | 70a17cd5a7aab52697b494cd8379fb78db15eeea (diff) | |
download | mariadb-git-33fc0d53b543032accea2476a4eed0522cead2bb.tar.gz |
Merge with 4.0
BitKeeper/etc/gone:
auto-union
BitKeeper/etc/ignore:
auto-union
BitKeeper/etc/logging_ok:
auto-union
BitKeeper/deleted/.del-.my_sys.h.swp~f6a4a7f8dae03f18:
Auto merged
BitKeeper/etc/config:
Auto merged
acconfig.h:
Auto merged
acinclude.m4:
Auto merged
Docs/manual.texi:
Auto merged
client/mysqlcheck.c:
Auto merged
client/mysqlshow.c:
Auto merged
include/myisam.h:
Auto merged
include/violite.h:
Auto merged
isam/pack_isam.c:
Auto merged
libmysql/libmysql.c:
Auto merged
libmysqld/lib_sql.cc:
Auto merged
myisam/Makefile.am:
Auto merged
myisam/ft_nlq_search.c:
Auto merged
myisam/mi_open.c:
Auto merged
myisam/mi_write.c:
Auto merged
myisam/sort.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/fulltext.result:
Auto merged
mysql-test/r/func_test.result:
Auto merged
mysql-test/r/isam.result:
Auto merged
mysql-test/r/rpl_replicate_do.result:
Auto merged
mysql-test/r/variables.result:
Auto merged
mysql-test/t/func_test.test:
Auto merged
mysql-test/t/myisam.test:
Auto merged
mysql-test/t/rpl_rotate_logs.test:
Auto merged
mysql-test/t/variables.test:
Auto merged
mysys/hash.c:
Auto merged
mysys/tree.c:
Auto merged
scripts/Makefile.am:
Auto merged
sql/Makefile.am:
Auto merged
sql/filesort.cc:
Auto merged
sql/gen_lex_hash.cc:
Auto merged
sql/ha_berkeley.cc:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/handler.h:
Auto merged
sql/hash_filo.h:
Auto merged
sql/hostname.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/lex.h:
Auto merged
sql/lock.cc:
Auto merged
sql/log.cc:
Auto merged
sql/log_event.h:
Auto merged
sql/mini_client.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/opt_sum.cc:
Auto merged
sql/repl_failsafe.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/slave.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_analyse.cc:
Auto merged
sql/sql_cache.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_load.cc:
Auto merged
sql/sql_rename.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_udf.cc:
Auto merged
sql/share/czech/errmsg.txt:
Auto merged
sql/share/danish/errmsg.txt:
Auto merged
sql/share/dutch/errmsg.txt:
Auto merged
sql/share/english/errmsg.txt:
Auto merged
sql/share/estonian/errmsg.txt:
Auto merged
sql/share/french/errmsg.txt:
Auto merged
sql/share/german/errmsg.txt:
Auto merged
sql/share/greek/errmsg.txt:
Auto merged
sql/share/hungarian/errmsg.txt:
Auto merged
sql/share/italian/errmsg.txt:
Auto merged
sql/share/japanese/errmsg.txt:
Auto merged
sql/share/korean/errmsg.txt:
Auto merged
sql/share/norwegian/errmsg.txt:
Auto merged
sql/table.h:
Auto merged
sql/unireg.cc:
Auto merged
sql-bench/server-cfg.sh:
Auto merged
sql/share/norwegian-ny/errmsg.txt:
Auto merged
sql/share/polish/errmsg.txt:
Auto merged
sql/share/portuguese/errmsg.txt:
Auto merged
sql/share/romanian/errmsg.txt:
Auto merged
sql/share/russian/errmsg.txt:
Auto merged
sql/share/slovak/errmsg.txt:
Auto merged
sql/share/spanish/errmsg.txt:
Auto merged
sql/share/swedish/errmsg.txt:
Auto merged
sql/share/ukrainian/errmsg.txt:
Auto merged
sql/ha_myisam.cc:
Merge with 4.0
Removed some commented code
sql/sql_db.cc:
Merge with 4.0
Optimized the logging of the drop db call a bit
sql/sql_update.cc:
Added comment
Diffstat (limited to 'vio')
-rw-r--r-- | vio/viossl.c | 46 | ||||
-rw-r--r-- | vio/viosslfactories.c | 6 |
2 files changed, 42 insertions, 10 deletions
diff --git a/vio/viossl.c b/vio/viossl.c index 56d3da8a1ac..cf1c98b5382 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -249,35 +249,48 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in) /* - TODO: Add documentation and error handling + TODO: Add documentation */ -void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) +int sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) { char *str; char buf[1024]; X509* client_cert; my_bool unused; + my_bool net_blocking; + enum enum_vio_type old_type; DBUG_ENTER("sslaccept"); DBUG_PRINT("enter", ("sd=%d ptr=%p", vio->sd,ptr)); + old_type= vio->type; + net_blocking = vio_is_blocking(vio); vio_blocking(vio, 1, &unused); /* Must be called before reset */ vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); vio->ssl_=0; - vio->open_=FALSE; if (!(vio->ssl_ = SSL_new(ptr->ssl_context_))) { DBUG_PRINT("error", ("SSL_new failure")); report_errors(); - DBUG_VOID_RETURN; + vio_reset(vio, old_type,vio->sd,0,FALSE); + vio_blocking(vio, net_blocking, &unused); + DBUG_RETURN(1); } DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); SSL_clear(vio->ssl_); SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); SSL_set_fd(vio->ssl_,vio->sd); SSL_set_accept_state(vio->ssl_); - SSL_do_handshake(vio->ssl_); - vio->open_ = TRUE; + if (SSL_do_handshake(vio->ssl_) < 1) + { + DBUG_PRINT("error", ("SSL_do_handshake failure")); + report_errors(); + SSL_free(vio->ssl_); + vio->ssl_=0; + vio_reset(vio, old_type,vio->sd,0,FALSE); + vio_blocking(vio, net_blocking, &unused); + DBUG_RETURN(1); + } #ifndef DBUF_OFF DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" ,SSL_get_cipher_name(vio->ssl_))); @@ -309,7 +322,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) } #endif - DBUG_VOID_RETURN; + DBUG_RETURN(0); } @@ -318,17 +331,22 @@ int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) char *str; X509* server_cert; my_bool unused; + my_bool net_blocking; + enum enum_vio_type old_type; DBUG_ENTER("sslconnect"); DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context_)); + old_type= vio->type; + net_blocking = vio_is_blocking(vio); vio_blocking(vio, 1, &unused); /* Must be called before reset */ vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); vio->ssl_=0; - vio->open_=FALSE; if (!(vio->ssl_ = SSL_new(ptr->ssl_context_))) { DBUG_PRINT("error", ("SSL_new failure")); report_errors(); + vio_reset(vio, old_type,vio->sd,0,FALSE); + vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); @@ -336,8 +354,16 @@ int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); SSL_set_fd (vio->ssl_, vio->sd); SSL_set_connect_state(vio->ssl_); - SSL_do_handshake(vio->ssl_); - vio->open_ = TRUE; + if (SSL_do_handshake(vio->ssl_) < 1) + { + DBUG_PRINT("error", ("SSL_do_handshake failure")); + report_errors(); + SSL_free(vio->ssl_); + vio->ssl_=0; + vio_reset(vio, old_type,vio->sd,0,FALSE); + vio_blocking(vio, net_blocking, &unused); + DBUG_RETURN(1); + } #ifndef DBUG_OFF DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" ,SSL_get_cipher_name(vio->ssl_))); diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 9e7a1475951..31bc457d1ae 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -93,7 +93,10 @@ vio_set_cert_stuff(SSL_CTX *ctx, const char *cert_file, const char *key_file) { DBUG_PRINT("error",("unable to get certificate from '%s'\n",cert_file)); /* FIX stderr */ + fprintf(stderr,"Error when connection to server using SSL:"); ERR_print_errors_fp(stderr); + fprintf(stderr,"Unable to get certificate from '%s'\n", cert_file); + fflush(stderr); DBUG_RETURN(0); } if (key_file == NULL) @@ -103,7 +106,10 @@ vio_set_cert_stuff(SSL_CTX *ctx, const char *cert_file, const char *key_file) { DBUG_PRINT("error", ("unable to get private key from '%s'\n",key_file)); /* FIX stderr */ + fprintf(stderr,"Error when connection to server using SSL:"); ERR_print_errors_fp(stderr); + fprintf(stderr,"Unable to get private key from '%s'\n", cert_file); + fflush(stderr); DBUG_RETURN(0); } |