Chromium Code Reviews| 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 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) | 5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) |
| 6 | 6 |
| 7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
| 8 #if defined(TARGET_OS_ANDROID) || defined(TARGET_OS_LINUX) || \ | 8 #if defined(TARGET_OS_ANDROID) || defined(TARGET_OS_LINUX) || \ |
| 9 defined(TARGET_OS_WINDOWS) || defined(TARGET_OS_FUCHSIA) | 9 defined(TARGET_OS_WINDOWS) || defined(TARGET_OS_FUCHSIA) |
| 10 | 10 |
| 11 #include "bin/secure_socket.h" | 11 #include "bin/secure_socket.h" |
| 12 #include "bin/secure_socket_boringssl.h" | 12 #include "bin/secure_socket_boringssl.h" |
| 13 | 13 |
| 14 #include <errno.h> | 14 #include <errno.h> |
| 15 #include <fcntl.h> | 15 #include <fcntl.h> |
| 16 #include <stdarg.h> | |
| 16 #include <stdio.h> | 17 #include <stdio.h> |
| 17 #include <string.h> | 18 #include <string.h> |
| 18 #include <sys/stat.h> | 19 #include <sys/stat.h> |
| 19 | 20 |
| 20 #include <openssl/bio.h> | 21 #include <openssl/bio.h> |
| 21 #include <openssl/err.h> | 22 #include <openssl/err.h> |
| 22 #include <openssl/pkcs12.h> | 23 #include <openssl/pkcs12.h> |
| 23 #include <openssl/safestack.h> | 24 #include <openssl/safestack.h> |
| 24 #include <openssl/ssl.h> | 25 #include <openssl/ssl.h> |
| 25 #include <openssl/tls1.h> | 26 #include <openssl/tls1.h> |
| 26 #include <openssl/x509.h> | 27 #include <openssl/x509.h> |
| 27 | 28 |
| 28 #include "bin/builtin.h" | 29 #include "bin/builtin.h" |
| 29 #include "bin/dartutils.h" | 30 #include "bin/dartutils.h" |
| 30 #include "bin/directory.h" | 31 #include "bin/directory.h" |
| 31 #include "bin/file.h" | 32 #include "bin/file.h" |
| 32 #include "bin/lockers.h" | 33 #include "bin/lockers.h" |
| 33 #include "bin/log.h" | 34 #include "bin/log.h" |
| 34 #include "bin/socket.h" | 35 #include "bin/socket.h" |
| 35 #include "bin/thread.h" | 36 #include "bin/thread.h" |
| 36 #include "bin/utils.h" | 37 #include "bin/utils.h" |
| 38 #include "platform/text_buffer.h" | |
| 37 #include "platform/utils.h" | 39 #include "platform/utils.h" |
| 38 | 40 |
| 39 #include "include/dart_api.h" | 41 #include "include/dart_api.h" |
| 40 | 42 |
| 41 // Return the error from the containing function if handle is an error handle. | 43 // Return the error from the containing function if handle is an error handle. |
| 42 #define RETURN_IF_ERROR(handle) \ | 44 #define RETURN_IF_ERROR(handle) \ |
| 43 { \ | 45 { \ |
| 44 Dart_Handle __handle = handle; \ | 46 Dart_Handle __handle = handle; \ |
| 45 if (Dart_IsError((__handle))) { \ | 47 if (Dart_IsError((__handle))) { \ |
| 46 return __handle; \ | 48 return __handle; \ |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 71 static const int kX509NativeFieldIndex = 0; | 73 static const int kX509NativeFieldIndex = 0; |
| 72 | 74 |
| 73 static const bool SSL_LOG_STATUS = false; | 75 static const bool SSL_LOG_STATUS = false; |
| 74 static const bool SSL_LOG_DATA = false; | 76 static const bool SSL_LOG_DATA = false; |
| 75 | 77 |
| 76 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000; | 78 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000; |
| 77 | 79 |
| 78 const char* commandline_root_certs_file = NULL; | 80 const char* commandline_root_certs_file = NULL; |
| 79 const char* commandline_root_certs_cache = NULL; | 81 const char* commandline_root_certs_cache = NULL; |
| 80 | 82 |
| 81 /* Get the error messages from BoringSSL, and put them in buffer as a | 83 // Get the error messages from BoringSSL, and put them in buffer as a |
| 82 * null-terminated string. */ | 84 // null-terminated string. |
| 83 static void FetchErrorString(char* buffer, int length) { | 85 static void FetchErrorString(const SSL* ssl, TextBuffer* text_buffer) { |
| 84 buffer[0] = '\0'; | 86 uint32_t error = 0; |
| 85 int error = ERR_get_error(); | 87 const char* path = NULL; |
| 86 while (error != 0) { | 88 int line = -1; |
| 87 int used = strlen(buffer); | 89 const char* sep = File::PathSeparator(); |
| 88 int free_length = length - used; | 90 do { |
| 89 if (free_length > 16) { | 91 error = ERR_get_error_line(&path, &line); |
| 90 // Enough room for error code at least. | 92 const char* file = strrchr(path, sep[0]); |
| 91 if (used > 0) { | 93 path = file ? file + 1 : path; |
| 92 buffer[used] = '\n'; | 94 if (ssl && |
|
rmacnak
2017/02/06 22:57:37
ssl != NULL
zra
2017/02/07 15:45:15
Done.
| |
| 93 buffer[used + 1] = '\0'; | 95 error == ERR_PACK(ERR_R_SSL_LIB, SSL_R_CERTIFICATE_VERIFY_FAILED)) { |
| 94 used++; | 96 intptr_t result = SSL_get_verify_result(ssl); |
| 95 free_length--; | 97 text_buffer->Printf("\n\t%s: %s (%s:%d)", ERR_reason_error_string(error), |
| 96 } | 98 X509_verify_cert_error_string(result), path, line); |
| 97 ERR_error_string_n(error, buffer + used, free_length); | 99 } else if (error != 0) { |
| 98 // ERR_error_string_n is guaranteed to leave a null-terminated string. | 100 text_buffer->Printf("\n\t%s (%s:%d)", ERR_reason_error_string(error), |
| 101 path, line); | |
| 99 } | 102 } |
| 100 error = ERR_get_error(); | 103 } while (error != 0); |
| 101 } | |
| 102 } | 104 } |
| 103 | 105 |
| 104 | 106 |
| 105 /* Handle an error reported from the BoringSSL library. */ | 107 // Handle an error reported from the BoringSSL library. |
| 106 static void ThrowIOException(int status, | 108 static void ThrowIOException(int status, |
| 107 const char* exception_type, | 109 const char* exception_type, |
| 108 const char* message) { | 110 const char* message, |
| 109 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; | 111 const SSL* ssl) { |
| 110 FetchErrorString(error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); | |
| 111 Dart_Handle exception; | 112 Dart_Handle exception; |
| 112 { | 113 { |
| 113 OSError os_error_struct(status, error_string, OSError::kBoringSSL); | 114 TextBuffer error_string(SSL_ERROR_MESSAGE_BUFFER_SIZE); |
| 115 FetchErrorString(ssl, &error_string); | |
| 116 OSError os_error_struct(status, error_string.buf(), OSError::kBoringSSL); | |
| 114 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); | 117 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); |
| 115 exception = | 118 exception = |
| 116 DartUtils::NewDartIOException(exception_type, message, os_error); | 119 DartUtils::NewDartIOException(exception_type, message, os_error); |
| 117 ASSERT(!Dart_IsError(exception)); | 120 ASSERT(!Dart_IsError(exception)); |
| 118 } | 121 } |
| 119 Dart_ThrowException(exception); | 122 Dart_ThrowException(exception); |
| 120 UNREACHABLE(); | 123 UNREACHABLE(); |
| 121 } | 124 } |
| 122 | 125 |
| 123 | 126 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 | 444 |
| 442 | 445 |
| 443 int PasswordCallback(char* buf, int size, int rwflag, void* userdata) { | 446 int PasswordCallback(char* buf, int size, int rwflag, void* userdata) { |
| 444 char* password = static_cast<char*>(userdata); | 447 char* password = static_cast<char*>(userdata); |
| 445 ASSERT(size == PEM_BUFSIZE); | 448 ASSERT(size == PEM_BUFSIZE); |
| 446 strncpy(buf, password, size); | 449 strncpy(buf, password, size); |
| 447 return strlen(password); | 450 return strlen(password); |
| 448 } | 451 } |
| 449 | 452 |
| 450 | 453 |
| 451 void CheckStatus(int status, const char* type, const char* message) { | 454 void CheckStatusSSL(int status, |
| 455 const char* type, | |
| 456 const char* message, | |
| 457 const SSL* ssl) { | |
| 452 // TODO(24183): Take appropriate action on failed calls, | 458 // TODO(24183): Take appropriate action on failed calls, |
| 453 // throw exception that includes all messages from the error stack. | 459 // throw exception that includes all messages from the error stack. |
| 454 if (status == 1) { | 460 if (status == 1) { |
| 455 return; | 461 return; |
| 456 } | 462 } |
| 457 if (SSL_LOG_STATUS) { | 463 if (SSL_LOG_STATUS) { |
| 458 int error = ERR_get_error(); | 464 int error = ERR_get_error(); |
| 459 Log::PrintErr("Failed: %s status %d", message, status); | 465 Log::PrintErr("Failed: %s status %d", message, status); |
| 460 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; | 466 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; |
| 461 ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); | 467 ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); |
| 462 Log::PrintErr("ERROR: %d %s\n", error, error_string); | 468 Log::PrintErr("ERROR: %d %s\n", error, error_string); |
| 463 } | 469 } |
| 464 ThrowIOException(status, type, message); | 470 ThrowIOException(status, type, message, ssl); |
| 465 } | 471 } |
| 466 | 472 |
| 467 | 473 |
| 474 void CheckStatus(int status, const char* type, const char* message) { | |
| 475 CheckStatusSSL(status, type, message, NULL); | |
| 476 } | |
| 477 | |
| 478 | |
| 468 // Where the argument to the constructor is the handle for an object | 479 // Where the argument to the constructor is the handle for an object |
| 469 // implementing List<int>, this class creates a scope in which a memory-backed | 480 // implementing List<int>, this class creates a scope in which a memory-backed |
| 470 // BIO is allocated. Leaving the scope cleans up the BIO and the buffer that | 481 // BIO is allocated. Leaving the scope cleans up the BIO and the buffer that |
| 471 // was used to create it. | 482 // was used to create it. |
| 472 // | 483 // |
| 473 // Do not make Dart_ API calls while in a ScopedMemBIO. | 484 // Do not make Dart_ API calls while in a ScopedMemBIO. |
| 474 // Do not call Dart_PropagateError while in a ScopedMemBIO. | 485 // Do not call Dart_PropagateError while in a ScopedMemBIO. |
| 475 class ScopedMemBIO { | 486 class ScopedMemBIO { |
| 476 public: | 487 public: |
| 477 explicit ScopedMemBIO(Dart_Handle object) { | 488 explicit ScopedMemBIO(Dart_Handle object) { |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 ASSERT((ERR_peek_error() == 0) || NoPEMStartLine()); | 820 ASSERT((ERR_peek_error() == 0) || NoPEMStartLine()); |
| 810 ERR_clear_error(); | 821 ERR_clear_error(); |
| 811 } | 822 } |
| 812 | 823 |
| 813 | 824 |
| 814 static void LoadRootCertFile(SSLContext* context, const char* file) { | 825 static void LoadRootCertFile(SSLContext* context, const char* file) { |
| 815 if (SSL_LOG_STATUS) { | 826 if (SSL_LOG_STATUS) { |
| 816 Log::Print("Looking for trusted roots in %s\n", file); | 827 Log::Print("Looking for trusted roots in %s\n", file); |
| 817 } | 828 } |
| 818 if (!File::Exists(file)) { | 829 if (!File::Exists(file)) { |
| 819 ThrowIOException(-1, "TlsException", "Failed to find root cert file"); | 830 ThrowIOException(-1, "TlsException", "Failed to find root cert file", NULL); |
| 820 } | 831 } |
| 821 int status = SSL_CTX_load_verify_locations(context->context(), file, NULL); | 832 int status = SSL_CTX_load_verify_locations(context->context(), file, NULL); |
| 822 CheckStatus(status, "TlsException", "Failure trusting builtin roots"); | 833 CheckStatus(status, "TlsException", "Failure trusting builtin roots"); |
| 823 if (SSL_LOG_STATUS) { | 834 if (SSL_LOG_STATUS) { |
| 824 Log::Print("Trusting roots from: %s\n", file); | 835 Log::Print("Trusting roots from: %s\n", file); |
| 825 } | 836 } |
| 826 } | 837 } |
| 827 | 838 |
| 828 | 839 |
| 829 static void LoadRootCertCache(SSLContext* context, const char* cache) { | 840 static void LoadRootCertCache(SSLContext* context, const char* cache) { |
| 830 if (SSL_LOG_STATUS) { | 841 if (SSL_LOG_STATUS) { |
| 831 Log::Print("Looking for trusted roots in %s\n", cache); | 842 Log::Print("Looking for trusted roots in %s\n", cache); |
| 832 } | 843 } |
| 833 if (Directory::Exists(cache) != Directory::EXISTS) { | 844 if (Directory::Exists(cache) != Directory::EXISTS) { |
| 834 ThrowIOException(-1, "TlsException", "Failed to find root cert cache"); | 845 ThrowIOException(-1, "TlsException", "Failed to find root cert cache", |
| 846 NULL); | |
| 835 } | 847 } |
| 836 int status = SSL_CTX_load_verify_locations(context->context(), NULL, cache); | 848 int status = SSL_CTX_load_verify_locations(context->context(), NULL, cache); |
| 837 CheckStatus(status, "TlsException", "Failure trusting builtin roots"); | 849 CheckStatus(status, "TlsException", "Failure trusting builtin roots"); |
| 838 if (SSL_LOG_STATUS) { | 850 if (SSL_LOG_STATUS) { |
| 839 Log::Print("Trusting roots from: %s\n", cache); | 851 Log::Print("Trusting roots from: %s\n", cache); |
| 840 } | 852 } |
| 841 } | 853 } |
| 842 | 854 |
| 843 | 855 |
| 844 void FUNCTION_NAME(SecurityContext_TrustBuiltinRoots)( | 856 void FUNCTION_NAME(SecurityContext_TrustBuiltinRoots)( |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1186 if (filter->ProcessAllBuffers(starts, ends, in_handshake)) { | 1198 if (filter->ProcessAllBuffers(starts, ends, in_handshake)) { |
| 1187 CObjectArray* result = | 1199 CObjectArray* result = |
| 1188 new CObjectArray(CObject::NewArray(SSLFilter::kNumBuffers * 2)); | 1200 new CObjectArray(CObject::NewArray(SSLFilter::kNumBuffers * 2)); |
| 1189 for (int i = 0; i < SSLFilter::kNumBuffers; ++i) { | 1201 for (int i = 0; i < SSLFilter::kNumBuffers; ++i) { |
| 1190 result->SetAt(2 * i, new CObjectInt32(CObject::NewInt32(starts[i]))); | 1202 result->SetAt(2 * i, new CObjectInt32(CObject::NewInt32(starts[i]))); |
| 1191 result->SetAt(2 * i + 1, new CObjectInt32(CObject::NewInt32(ends[i]))); | 1203 result->SetAt(2 * i + 1, new CObjectInt32(CObject::NewInt32(ends[i]))); |
| 1192 } | 1204 } |
| 1193 return result; | 1205 return result; |
| 1194 } else { | 1206 } else { |
| 1195 int32_t error_code = static_cast<int32_t>(ERR_peek_error()); | 1207 int32_t error_code = static_cast<int32_t>(ERR_peek_error()); |
| 1196 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; | 1208 TextBuffer error_string(SSL_ERROR_MESSAGE_BUFFER_SIZE); |
| 1197 FetchErrorString(error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); | 1209 FetchErrorString(filter->ssl_, &error_string); |
| 1198 CObjectArray* result = new CObjectArray(CObject::NewArray(2)); | 1210 CObjectArray* result = new CObjectArray(CObject::NewArray(2)); |
| 1199 result->SetAt(0, new CObjectInt32(CObject::NewInt32(error_code))); | 1211 result->SetAt(0, new CObjectInt32(CObject::NewInt32(error_code))); |
| 1200 result->SetAt(1, new CObjectString(CObject::NewString(error_string))); | 1212 result->SetAt(1, new CObjectString(CObject::NewString(error_string.buf()))); |
| 1201 return result; | 1213 return result; |
| 1202 } | 1214 } |
| 1203 } | 1215 } |
| 1204 | 1216 |
| 1205 | 1217 |
| 1206 bool SSLFilter::ProcessAllBuffers(int starts[kNumBuffers], | 1218 bool SSLFilter::ProcessAllBuffers(int starts[kNumBuffers], |
| 1207 int ends[kNumBuffers], | 1219 int ends[kNumBuffers], |
| 1208 bool in_handshake) { | 1220 bool in_handshake) { |
| 1209 for (int i = 0; i < kNumBuffers; ++i) { | 1221 for (int i = 0; i < kNumBuffers; ++i) { |
| 1210 if (in_handshake && (i == kReadPlaintext || i == kWritePlaintext)) continue; | 1222 if (in_handshake && (i == kReadPlaintext || i == kWritePlaintext)) continue; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1507 is_server_ = is_server; | 1519 is_server_ = is_server; |
| 1508 if (in_handshake_) { | 1520 if (in_handshake_) { |
| 1509 FATAL("Connect called twice on the same _SecureFilter."); | 1521 FATAL("Connect called twice on the same _SecureFilter."); |
| 1510 } | 1522 } |
| 1511 | 1523 |
| 1512 int status; | 1524 int status; |
| 1513 int error; | 1525 int error; |
| 1514 BIO* ssl_side; | 1526 BIO* ssl_side; |
| 1515 status = BIO_new_bio_pair(&ssl_side, kInternalBIOSize, &socket_side_, | 1527 status = BIO_new_bio_pair(&ssl_side, kInternalBIOSize, &socket_side_, |
| 1516 kInternalBIOSize); | 1528 kInternalBIOSize); |
| 1517 CheckStatus(status, "TlsException", "BIO_new_bio_pair"); | 1529 CheckStatusSSL(status, "TlsException", "BIO_new_bio_pair", ssl_); |
| 1518 | 1530 |
| 1519 assert(context != NULL); | 1531 assert(context != NULL); |
| 1520 ssl_ = SSL_new(context); | 1532 ssl_ = SSL_new(context); |
| 1521 SSL_set_bio(ssl_, ssl_side, ssl_side); | 1533 SSL_set_bio(ssl_, ssl_side, ssl_side); |
| 1522 SSL_set_mode(ssl_, SSL_MODE_AUTO_RETRY); // TODO(whesse): Is this right? | 1534 SSL_set_mode(ssl_, SSL_MODE_AUTO_RETRY); // TODO(whesse): Is this right? |
| 1523 SSL_set_ex_data(ssl_, filter_ssl_index, this); | 1535 SSL_set_ex_data(ssl_, filter_ssl_index, this); |
| 1524 | 1536 |
| 1525 if (is_server_) { | 1537 if (is_server_) { |
| 1526 int certificate_mode = | 1538 int certificate_mode = |
| 1527 request_client_certificate ? SSL_VERIFY_PEER : SSL_VERIFY_NONE; | 1539 request_client_certificate ? SSL_VERIFY_PEER : SSL_VERIFY_NONE; |
| 1528 if (require_client_certificate) { | 1540 if (require_client_certificate) { |
| 1529 certificate_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; | 1541 certificate_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; |
| 1530 } | 1542 } |
| 1531 SSL_set_verify(ssl_, certificate_mode, NULL); | 1543 SSL_set_verify(ssl_, certificate_mode, NULL); |
| 1532 } else { | 1544 } else { |
| 1533 SetAlpnProtocolList(protocols_handle, ssl_, NULL, false); | 1545 SetAlpnProtocolList(protocols_handle, ssl_, NULL, false); |
| 1534 status = SSL_set_tlsext_host_name(ssl_, hostname); | 1546 status = SSL_set_tlsext_host_name(ssl_, hostname); |
| 1535 CheckStatus(status, "TlsException", "Set SNI host name"); | 1547 CheckStatusSSL(status, "TlsException", "Set SNI host name", ssl_); |
| 1536 // Sets the hostname in the certificate-checking object, so it is checked | 1548 // Sets the hostname in the certificate-checking object, so it is checked |
| 1537 // against the certificate presented by the server. | 1549 // against the certificate presented by the server. |
| 1538 X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_); | 1550 X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_); |
| 1539 hostname_ = strdup(hostname); | 1551 hostname_ = strdup(hostname); |
| 1540 X509_VERIFY_PARAM_set_flags( | 1552 X509_VERIFY_PARAM_set_flags( |
| 1541 certificate_checking_parameters, | 1553 certificate_checking_parameters, |
| 1542 X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_TRUSTED_FIRST); | 1554 X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_TRUSTED_FIRST); |
| 1543 X509_VERIFY_PARAM_set_hostflags(certificate_checking_parameters, 0); | 1555 X509_VERIFY_PARAM_set_hostflags(certificate_checking_parameters, 0); |
| 1544 status = X509_VERIFY_PARAM_set1_host(certificate_checking_parameters, | 1556 status = X509_VERIFY_PARAM_set1_host(certificate_checking_parameters, |
| 1545 hostname_, strlen(hostname_)); | 1557 hostname_, strlen(hostname_)); |
| 1546 CheckStatus(status, "TlsException", | 1558 CheckStatusSSL(status, "TlsException", |
| 1547 "Set hostname for certificate checking"); | 1559 "Set hostname for certificate checking", ssl_); |
| 1548 } | 1560 } |
| 1549 // Make the connection: | 1561 // Make the connection: |
| 1550 if (is_server_) { | 1562 if (is_server_) { |
| 1551 status = SSL_accept(ssl_); | 1563 status = SSL_accept(ssl_); |
| 1552 if (SSL_LOG_STATUS) { | 1564 if (SSL_LOG_STATUS) { |
| 1553 Log::Print("SSL_accept status: %d\n", status); | 1565 Log::Print("SSL_accept status: %d\n", status); |
| 1554 } | 1566 } |
| 1555 if (status != 1) { | 1567 if (status != 1) { |
| 1556 // TODO(whesse): expect a needs-data error here. Handle other errors. | 1568 // TODO(whesse): expect a needs-data error here. Handle other errors. |
| 1557 error = SSL_get_error(ssl_, status); | 1569 error = SSL_get_error(ssl_, status); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1590 // The SSL_do_handshake will try performing a handshake and might call | 1602 // The SSL_do_handshake will try performing a handshake and might call |
| 1591 // a CertificateCallback. If the certificate validation | 1603 // a CertificateCallback. If the certificate validation |
| 1592 // failed the 'callback_error" will be set by the certificateCallback | 1604 // failed the 'callback_error" will be set by the certificateCallback |
| 1593 // logic and we propagate the error" | 1605 // logic and we propagate the error" |
| 1594 Dart_PropagateError(callback_error); | 1606 Dart_PropagateError(callback_error); |
| 1595 } | 1607 } |
| 1596 if (SSL_want_write(ssl_) || SSL_want_read(ssl_)) { | 1608 if (SSL_want_write(ssl_) || SSL_want_read(ssl_)) { |
| 1597 in_handshake_ = true; | 1609 in_handshake_ = true; |
| 1598 return; | 1610 return; |
| 1599 } | 1611 } |
| 1600 CheckStatus(status, "HandshakeException", is_server_ | 1612 CheckStatusSSL( |
| 1601 ? "Handshake error in server" | 1613 status, "HandshakeException", |
| 1602 : "Handshake error in client"); | 1614 is_server_ ? "Handshake error in server" : "Handshake error in client", |
| 1615 ssl_); | |
| 1603 // Handshake succeeded. | 1616 // Handshake succeeded. |
| 1604 if (in_handshake_) { | 1617 if (in_handshake_) { |
| 1605 // TODO(24071): Check return value of SSL_get_verify_result, this | 1618 // TODO(24071): Check return value of SSL_get_verify_result, this |
| 1606 // should give us the hostname check. | 1619 // should give us the hostname check. |
| 1607 int result = SSL_get_verify_result(ssl_); | 1620 int result = SSL_get_verify_result(ssl_); |
| 1608 if (SSL_LOG_STATUS) { | 1621 if (SSL_LOG_STATUS) { |
| 1609 Log::Print("Handshake verification status: %d\n", result); | 1622 Log::Print("Handshake verification status: %d\n", result); |
| 1610 X509* peer_certificate = SSL_get_peer_certificate(ssl_); | 1623 X509* peer_certificate = SSL_get_peer_certificate(ssl_); |
| 1611 if (peer_certificate == NULL) { | 1624 if (peer_certificate == NULL) { |
| 1612 Log::Print("No peer certificate received\n"); | 1625 Log::Print("No peer certificate received\n"); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1773 return bytes_processed; | 1786 return bytes_processed; |
| 1774 } | 1787 } |
| 1775 | 1788 |
| 1776 } // namespace bin | 1789 } // namespace bin |
| 1777 } // namespace dart | 1790 } // namespace dart |
| 1778 | 1791 |
| 1779 #endif // defined(TARGET_OS_LINUX) | 1792 #endif // defined(TARGET_OS_LINUX) |
| 1780 | 1793 |
| 1781 #endif // !defined(DART_IO_DISABLED) && | 1794 #endif // !defined(DART_IO_DISABLED) && |
| 1782 // !defined(DART_IO_SECURE_SOCKET_DISABLED) | 1795 // !defined(DART_IO_SECURE_SOCKET_DISABLED) |
| OLD | NEW |