| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/secure_socket.h" | 5 #include "bin/secure_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 static_cast<void*>(this)); | 553 static_cast<void*>(this)); |
| 554 | 554 |
| 555 PRBool as_server = is_server ? PR_TRUE : PR_FALSE; | 555 PRBool as_server = is_server ? PR_TRUE : PR_FALSE; |
| 556 status = SSL_ResetHandshake(filter_, as_server); | 556 status = SSL_ResetHandshake(filter_, as_server); |
| 557 if (status != SECSuccess) { | 557 if (status != SECSuccess) { |
| 558 ThrowPRException("Failed SSL_ResetHandshake call"); | 558 ThrowPRException("Failed SSL_ResetHandshake call"); |
| 559 } | 559 } |
| 560 | 560 |
| 561 // SetPeerAddress | 561 // SetPeerAddress |
| 562 PRNetAddr host_address; | 562 PRNetAddr host_address; |
| 563 char host_entry_buffer[PR_NETDB_BUF_SIZE]; | 563 PRAddrInfo* info = PR_GetAddrInfoByName(host_name, |
| 564 PRHostEnt host_entry; | 564 PR_AF_UNSPEC, |
| 565 PRStatus rv = PR_GetHostByName(host_name, host_entry_buffer, | 565 PR_AI_ADDRCONFIG); |
| 566 PR_NETDB_BUF_SIZE, &host_entry); | 566 if (info == NULL) { |
| 567 if (rv != PR_SUCCESS) { | 567 ThrowPRException("Failed PR_GetAddrInfoByName call"); |
| 568 ThrowPRException("Failed PR_GetHostByName call"); | |
| 569 } | 568 } |
| 570 | 569 |
| 571 int index = PR_EnumerateHostEnt(0, &host_entry, port, &host_address); | 570 PR_EnumerateAddrInfo(0, info, port, &host_address); |
| 572 if (index == -1 || index == 0) { | 571 |
| 573 ThrowPRException("Failed PR_EnumerateHostEnt call"); | |
| 574 } | |
| 575 memio_SetPeerName(filter_, &host_address); | 572 memio_SetPeerName(filter_, &host_address); |
| 573 PR_FreeAddrInfo(info); |
| 576 } | 574 } |
| 577 | 575 |
| 578 | 576 |
| 579 void SSLFilter::Handshake() { | 577 void SSLFilter::Handshake() { |
| 580 SECStatus status = SSL_ForceHandshake(filter_); | 578 SECStatus status = SSL_ForceHandshake(filter_); |
| 581 if (status == SECSuccess) { | 579 if (status == SECSuccess) { |
| 582 if (in_handshake_) { | 580 if (in_handshake_) { |
| 583 ThrowIfError(Dart_InvokeClosure(handshake_complete_, 0, NULL)); | 581 ThrowIfError(Dart_InvokeClosure(handshake_complete_, 0, NULL)); |
| 584 in_handshake_ = false; | 582 in_handshake_ = false; |
| 585 } | 583 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 if (PR_WOULD_BLOCK_ERROR != pr_error) { | 707 if (PR_WOULD_BLOCK_ERROR != pr_error) { |
| 710 ThrowPRException("Error reading plaintext from SSLFilter"); | 708 ThrowPRException("Error reading plaintext from SSLFilter"); |
| 711 } | 709 } |
| 712 bytes_processed = 0; | 710 bytes_processed = 0; |
| 713 } | 711 } |
| 714 break; | 712 break; |
| 715 } | 713 } |
| 716 } | 714 } |
| 717 return bytes_processed; | 715 return bytes_processed; |
| 718 } | 716 } |
| OLD | NEW |