Changeset 3e94bd3 in mod_gnutls for src/gnutls_io.c
- Timestamp:
- Jan 11, 2013, 12:54:56 AM (10 years ago)
- Branches:
- debian/master, debian/stretch-backports, jessie-backports, upstream
- Children:
- 1c87791, 70c2d86
- Parents:
- 8eb6ccd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gnutls_io.c
r8eb6ccd r3e94bd3 36 36 apr_status_t status) 37 37 { 38 m od_gnutls_handle_t *ctxt = (mod_gnutls_handle_t *) f->ctx;38 mgs_handle_t *ctxt = (mgs_handle_t *) f->ctx; 39 39 apr_bucket *bucket; 40 40 … … 64 64 } 65 65 66 static int char_buffer_read(m od_gnutls_char_buffer_t * buffer, char *in,66 static int char_buffer_read(mgs_char_buffer_t * buffer, char *in, 67 67 int inl) 68 68 { … … 88 88 } 89 89 90 static int char_buffer_write(m od_gnutls_char_buffer_t * buffer, char *in,90 static int char_buffer_write(mgs_char_buffer_t * buffer, char *in, 91 91 int inl) 92 92 { … … 182 182 183 183 184 static apr_status_t gnutls_io_input_read(m od_gnutls_handle_t * ctxt,184 static apr_status_t gnutls_io_input_read(mgs_handle_t * ctxt, 185 185 char *buf, apr_size_t * len) 186 186 { … … 311 311 } 312 312 313 static apr_status_t gnutls_io_input_getline(m od_gnutls_handle_t * ctxt,313 static apr_status_t gnutls_io_input_getline(mgs_handle_t * ctxt, 314 314 char *buf, apr_size_t * len) 315 315 { … … 354 354 } 355 355 356 357 static void gnutls_do_handshake(mod_gnutls_handle_t * ctxt) 356 static int gnutls_do_handshake(mgs_handle_t * ctxt) 358 357 { 359 358 int ret; 360 359 int errcode; 361 360 if (ctxt->status != 0) { 362 return ;361 return -1; 363 362 } 364 363 365 364 tryagain: 366 367 ret = gnutls_handshake(ctxt->session); 365 do { 366 ret = gnutls_handshake(ctxt->session); 367 } while (ret == GNUTLS_E_AGAIN); 368 368 369 if (ret < 0) { 369 370 if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED … … 381 382 goto tryagain; 382 383 } 383 384 #if USING_2_1_RECENT 385 ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, ctxt->c, 386 "GnuTLS: Handshake Failed (%d) '%s'", ret, 387 gnutls_strerror(ret)); 388 #else 384 389 ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctxt->c->base_server, 385 390 "GnuTLS: Handshake Failed (%d) '%s'", ret, 386 gnutls_strerror(ret)); 391 gnutls_strerror(ret)); 392 #endif 387 393 ctxt->status = -1; 388 394 gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, 389 395 gnutls_error_to_alert(ret, NULL)); 390 396 gnutls_deinit(ctxt->session); 391 return ;397 return ret; 392 398 } 393 399 else { 400 /* all done with the handshake */ 394 401 ctxt->status = 1; 395 return; /* all done with the handshake */ 396 } 397 } 398 399 400 apr_status_t mod_gnutls_filter_input(ap_filter_t* f, 402 /* If the session was resumed, we did not set the correct 403 * server_rec in ctxt->sc. Go Find it. (ick!) 404 */ 405 if (gnutls_session_is_resumed(ctxt->session)) { 406 mgs_srvconf_rec* sc; 407 sc = mgs_find_sni_server(ctxt->session); 408 if (sc) { 409 ctxt->sc = sc; 410 } 411 } 412 return 0; 413 } 414 } 415 416 int mgs_rehandshake(mgs_handle_t * ctxt) 417 { 418 int rv; 419 420 rv = gnutls_rehandshake(ctxt->session); 421 422 if (rv != 0) { 423 /* the client did not want to rehandshake. goodbye */ 424 ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctxt->c->base_server, 425 "GnuTLS: Client Refused Rehandshake request."); 426 return -1; 427 } 428 429 ctxt->status = 0; 430 431 rv = gnutls_do_handshake(ctxt); 432 433 return rv; 434 } 435 436 437 apr_status_t mgs_filter_input(ap_filter_t* f, 401 438 apr_bucket_brigade * bb, 402 439 ap_input_mode_t mode, … … 405 442 { 406 443 apr_status_t status = APR_SUCCESS; 407 m od_gnutls_handle_t *ctxt = (mod_gnutls_handle_t *) f->ctx;444 mgs_handle_t *ctxt = (mgs_handle_t *) f->ctx; 408 445 apr_size_t len = sizeof(ctxt->input_buffer); 409 446 … … 415 452 416 453 if (ctxt->status == 0) { 417 char* server_name;418 int server_type;419 int data_len = 256;420 421 454 gnutls_do_handshake(ctxt); 422 423 /**424 * Due to issues inside the GnuTLS API, we cannot currently do TLS 1.1425 * Server Name Indication.426 */427 server_name = apr_palloc(ctxt->c->pool, data_len);428 if (gnutls_server_name_get(ctxt->session, server_name, &data_len, &server_type, 0) == 0) {429 if (server_type == GNUTLS_NAME_DNS) {430 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,431 ctxt->c->base_server,432 "GnuTLS: TLS 1.1 Server Name: "433 "%s", server_name);434 435 }436 }437 455 } 438 456 … … 481 499 } 482 500 483 apr_status_t m od_gnutls_filter_output(ap_filter_t * f,501 apr_status_t mgs_filter_output(ap_filter_t * f, 484 502 apr_bucket_brigade * bb) 485 503 { 486 504 apr_size_t ret; 487 505 apr_bucket* e; 488 m od_gnutls_handle_t *ctxt = (mod_gnutls_handle_t *) f->ctx;506 mgs_handle_t *ctxt = (mgs_handle_t *) f->ctx; 489 507 apr_status_t status = APR_SUCCESS; 490 508 apr_read_type_e rblock = APR_NONBLOCK_READ; … … 585 603 } 586 604 587 ssize_t m od_gnutls_transport_read(gnutls_transport_ptr_t ptr,605 ssize_t mgs_transport_read(gnutls_transport_ptr_t ptr, 588 606 void *buffer, size_t len) 589 607 { 590 m od_gnutls_handle_t *ctxt = ptr;608 mgs_handle_t *ctxt = ptr; 591 609 apr_status_t rc; 592 610 apr_size_t in = len; … … 652 670 653 671 654 static ssize_t write_flush(m od_gnutls_handle_t * ctxt)672 static ssize_t write_flush(mgs_handle_t * ctxt) 655 673 { 656 674 apr_bucket *e; … … 684 702 } 685 703 686 ssize_t m od_gnutls_transport_write(gnutls_transport_ptr_t ptr,704 ssize_t mgs_transport_write(gnutls_transport_ptr_t ptr, 687 705 const void *buffer, size_t len) 688 706 { 689 m od_gnutls_handle_t *ctxt = ptr;707 mgs_handle_t *ctxt = ptr; 690 708 691 709 /* pass along the encrypted data
Note: See TracChangeset
for help on using the changeset viewer.