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(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) || \ | 8 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) || \ |
9 defined(HOST_OS_WINDOWS) || defined(HOST_OS_FUCHSIA) | 9 defined(HOST_OS_WINDOWS) || defined(HOST_OS_FUCHSIA) |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 static const bool SSL_LOG_DATA = false; | 76 static const bool SSL_LOG_DATA = false; |
77 | 77 |
78 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000; | 78 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000; |
79 | 79 |
80 const char* commandline_root_certs_file = NULL; | 80 const char* commandline_root_certs_file = NULL; |
81 const char* commandline_root_certs_cache = NULL; | 81 const char* commandline_root_certs_cache = NULL; |
82 | 82 |
83 // 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 |
84 // null-terminated string. | 84 // null-terminated string. |
85 static void FetchErrorString(const SSL* ssl, TextBuffer* text_buffer) { | 85 static void FetchErrorString(const SSL* ssl, TextBuffer* text_buffer) { |
86 uint32_t error = 0; | |
87 const char* path = NULL; | |
88 int line = -1; | |
89 const char* sep = File::PathSeparator(); | 86 const char* sep = File::PathSeparator(); |
90 do { | 87 while (true) { |
91 error = ERR_get_error_line(&path, &line); | 88 const char* path = NULL; |
92 const char* file = strrchr(path, sep[0]); | 89 int line = -1; |
93 path = file ? file + 1 : path; | 90 uint32_t error = ERR_get_error_line(&path, &line); |
| 91 if (error == 0) { |
| 92 break; |
| 93 } |
| 94 text_buffer->Printf("\n\t%s", ERR_reason_error_string(error)); |
94 if ((ssl != NULL) && (ERR_GET_LIB(error) == ERR_LIB_SSL) && | 95 if ((ssl != NULL) && (ERR_GET_LIB(error) == ERR_LIB_SSL) && |
95 (ERR_GET_REASON(error) == SSL_R_CERTIFICATE_VERIFY_FAILED)) { | 96 (ERR_GET_REASON(error) == SSL_R_CERTIFICATE_VERIFY_FAILED)) { |
96 intptr_t result = SSL_get_verify_result(ssl); | 97 intptr_t result = SSL_get_verify_result(ssl); |
97 text_buffer->Printf("\n\t%s: %s (%s:%d)", ERR_reason_error_string(error), | 98 text_buffer->Printf(": %s", X509_verify_cert_error_string(result)); |
98 X509_verify_cert_error_string(result), path, line); | |
99 } else if (error != 0) { | |
100 text_buffer->Printf("\n\t%s (%s:%d)", ERR_reason_error_string(error), | |
101 path, line); | |
102 } | 99 } |
103 } while (error != 0); | 100 if ((path != NULL) && (line >= 0)) { |
| 101 const char* file = strrchr(path, sep[0]); |
| 102 path = file ? file + 1 : path; |
| 103 text_buffer->Printf("(%s:%d)", path, line); |
| 104 } |
| 105 } |
104 } | 106 } |
105 | 107 |
106 | 108 |
107 // Handle an error reported from the BoringSSL library. | 109 // Handle an error reported from the BoringSSL library. |
108 static void ThrowIOException(int status, | 110 static void ThrowIOException(int status, |
109 const char* exception_type, | 111 const char* exception_type, |
110 const char* message, | 112 const char* message, |
111 const SSL* ssl) { | 113 const SSL* ssl) { |
112 Dart_Handle exception; | 114 Dart_Handle exception; |
113 { | 115 { |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 return bytes_processed; | 1798 return bytes_processed; |
1797 } | 1799 } |
1798 | 1800 |
1799 } // namespace bin | 1801 } // namespace bin |
1800 } // namespace dart | 1802 } // namespace dart |
1801 | 1803 |
1802 #endif // defined(HOST_OS_LINUX) | 1804 #endif // defined(HOST_OS_LINUX) |
1803 | 1805 |
1804 #endif // !defined(DART_IO_DISABLED) && | 1806 #endif // !defined(DART_IO_DISABLED) && |
1805 // !defined(DART_IO_SECURE_SOCKET_DISABLED) | 1807 // !defined(DART_IO_SECURE_SOCKET_DISABLED) |
OLD | NEW |