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 PRAddrInfo* info = PR_GetAddrInfoByName(host_name, | 563 char host_entry_buffer[PR_NETDB_BUF_SIZE]; |
564 PR_AF_UNSPEC, | 564 PRHostEnt host_entry; |
565 PR_AI_ADDRCONFIG); | 565 PRStatus rv = PR_GetHostByName(host_name, host_entry_buffer, |
566 if (info == NULL) { | 566 PR_NETDB_BUF_SIZE, &host_entry); |
567 ThrowPRException("Failed PR_GetAddrInfoByName call"); | 567 if (rv != PR_SUCCESS) { |
| 568 ThrowPRException("Failed PR_GetHostByName call"); |
568 } | 569 } |
569 | 570 |
570 PR_EnumerateAddrInfo(0, info, port, &host_address); | 571 int index = PR_EnumerateHostEnt(0, &host_entry, port, &host_address); |
571 | 572 if (index == -1 || index == 0) { |
| 573 ThrowPRException("Failed PR_EnumerateHostEnt call"); |
| 574 } |
572 memio_SetPeerName(filter_, &host_address); | 575 memio_SetPeerName(filter_, &host_address); |
573 PR_FreeAddrInfo(info); | |
574 } | 576 } |
575 | 577 |
576 | 578 |
577 void SSLFilter::Handshake() { | 579 void SSLFilter::Handshake() { |
578 SECStatus status = SSL_ForceHandshake(filter_); | 580 SECStatus status = SSL_ForceHandshake(filter_); |
579 if (status == SECSuccess) { | 581 if (status == SECSuccess) { |
580 if (in_handshake_) { | 582 if (in_handshake_) { |
581 ThrowIfError(Dart_InvokeClosure(handshake_complete_, 0, NULL)); | 583 ThrowIfError(Dart_InvokeClosure(handshake_complete_, 0, NULL)); |
582 in_handshake_ = false; | 584 in_handshake_ = false; |
583 } | 585 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 if (PR_WOULD_BLOCK_ERROR != pr_error) { | 709 if (PR_WOULD_BLOCK_ERROR != pr_error) { |
708 ThrowPRException("Error reading plaintext from SSLFilter"); | 710 ThrowPRException("Error reading plaintext from SSLFilter"); |
709 } | 711 } |
710 bytes_processed = 0; | 712 bytes_processed = 0; |
711 } | 713 } |
712 break; | 714 break; |
713 } | 715 } |
714 } | 716 } |
715 return bytes_processed; | 717 return bytes_processed; |
716 } | 718 } |
OLD | NEW |