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> | |
10 #include <stdio.h> | 9 #include <stdio.h> |
11 #include <string.h> | 10 #include <string.h> |
| 11 #include <sys/stat.h> |
12 | 12 |
13 #include <openssl/bio.h> | 13 #include <openssl/bio.h> |
14 #include <openssl/err.h> | 14 #include <openssl/err.h> |
15 #include <openssl/pkcs12.h> | 15 #include <openssl/pkcs12.h> |
16 #include <openssl/safestack.h> | 16 #include <openssl/safestack.h> |
17 #include <openssl/ssl.h> | 17 #include <openssl/ssl.h> |
18 #include <openssl/tls1.h> | 18 #include <openssl/tls1.h> |
19 #include <openssl/x509.h> | 19 #include <openssl/x509.h> |
20 | 20 |
21 #include "bin/builtin.h" | 21 #include "bin/builtin.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // ERR_error_string_n is guaranteed to leave a null-terminated string. | 76 // ERR_error_string_n is guaranteed to leave a null-terminated string. |
77 } | 77 } |
78 error = ERR_get_error(); | 78 error = ERR_get_error(); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 /* Handle an error reported from the BoringSSL library. */ | 83 /* Handle an error reported from the BoringSSL library. */ |
84 static void ThrowIOException(int status, | 84 static void ThrowIOException(int status, |
85 const char* exception_type, | 85 const char* exception_type, |
86 const char* message, | 86 const char* message) { |
87 bool free_message = false) { | |
88 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; | 87 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; |
89 FetchErrorString(error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); | 88 FetchErrorString(error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); |
90 OSError os_error_struct(status, error_string, OSError::kBoringSSL); | 89 OSError os_error_struct(status, error_string, OSError::kBoringSSL); |
91 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); | 90 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); |
92 Dart_Handle exception = | 91 Dart_Handle exception = |
93 DartUtils::NewDartIOException(exception_type, message, os_error); | 92 DartUtils::NewDartIOException(exception_type, message, os_error); |
94 ASSERT(!Dart_IsError(exception)); | 93 ASSERT(!Dart_IsError(exception)); |
95 if (free_message) { | |
96 free(const_cast<char*>(message)); | |
97 } | |
98 Dart_ThrowException(exception); | 94 Dart_ThrowException(exception); |
99 UNREACHABLE(); | 95 UNREACHABLE(); |
100 } | 96 } |
101 | 97 |
102 | 98 |
103 static SSLFilter* GetFilter(Dart_NativeArguments args) { | 99 static SSLFilter* GetFilter(Dart_NativeArguments args) { |
104 SSLFilter* filter; | 100 SSLFilter* filter; |
105 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); | 101 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); |
106 ASSERT(Dart_IsInstance(dart_this)); | 102 ASSERT(Dart_IsInstance(dart_this)); |
107 ThrowIfError(Dart_GetNativeInstanceField( | 103 ThrowIfError(Dart_GetNativeInstanceField( |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 } else { | 1647 } else { |
1652 if (SSL_LOG_DATA) Log::Print( | 1648 if (SSL_LOG_DATA) Log::Print( |
1653 "WriteEncrypted BIO_read wrote %d bytes\n", bytes_processed); | 1649 "WriteEncrypted BIO_read wrote %d bytes\n", bytes_processed); |
1654 } | 1650 } |
1655 } | 1651 } |
1656 return bytes_processed; | 1652 return bytes_processed; |
1657 } | 1653 } |
1658 | 1654 |
1659 } // namespace bin | 1655 } // namespace bin |
1660 } // namespace dart | 1656 } // namespace dart |
OLD | NEW |