| 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 #ifndef BIN_SECURE_SOCKET_H_ | 5 #ifndef BIN_SECURE_SOCKET_H_ |
| 6 #define BIN_SECURE_SOCKET_H_ | 6 #define BIN_SECURE_SOCKET_H_ |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 static void ThrowException(const char* message) { | 28 static void ThrowException(const char* message) { |
| 29 Dart_Handle socket_io_exception = | 29 Dart_Handle socket_io_exception = |
| 30 DartUtils::NewDartSocketIOException(message, Dart_Null()); | 30 DartUtils::NewDartSocketIOException(message, Dart_Null()); |
| 31 Dart_ThrowException(socket_io_exception); | 31 Dart_ThrowException(socket_io_exception); |
| 32 } | 32 } |
| 33 | 33 |
| 34 | 34 |
| 35 /* Handle an error reported from the NSS library. */ | 35 /* Handle an error reported from the NSS library. */ |
| 36 static void ThrowPRException(const char* message) { | 36 static void ThrowPRException(const char* message) { |
| 37 PRErrorCode error_code = PR_GetError(); | 37 PRErrorCode error_code = PR_GetError(); |
| 38 int error_length = PR_GetErrorTextLength(); | 38 const char* error_message = PR_ErrorToString(error_code, PR_LANGUAGE_EN); |
| 39 char* error_message = static_cast<char*>(malloc(error_length + 1)); | |
| 40 ASSERT(error_message != NULL); | |
| 41 int copied_length = PR_GetErrorText(error_message); | |
| 42 ASSERT(copied_length == error_length); | |
| 43 error_message[error_length] = '\0'; | |
| 44 OSError os_error_struct(error_code, error_message, OSError::kNSS); | 39 OSError os_error_struct(error_code, error_message, OSError::kNSS); |
| 45 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); | 40 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); |
| 46 Dart_Handle socket_io_exception = | 41 Dart_Handle socket_io_exception = |
| 47 DartUtils::NewDartSocketIOException(message, os_error); | 42 DartUtils::NewDartSocketIOException(message, os_error); |
| 48 free(error_message); | |
| 49 Dart_ThrowException(socket_io_exception); | 43 Dart_ThrowException(socket_io_exception); |
| 50 } | 44 } |
| 51 | 45 |
| 52 /* | 46 /* |
| 53 * SSLFilter encapsulates the NSS SSL(TLS) code in a filter, that communicates | 47 * SSLFilter encapsulates the NSS SSL(TLS) code in a filter, that communicates |
| 54 * with the containing _SecureFilterImpl Dart object through four shared | 48 * with the containing _SecureFilterImpl Dart object through four shared |
| 55 * ExternalByteArray buffers, for reading and writing plaintext, and | 49 * ExternalByteArray buffers, for reading and writing plaintext, and |
| 56 * reading and writing encrypted text. The filter handles handshaking | 50 * reading and writing encrypted text. The filter handles handshaking |
| 57 * and certificate verification. | 51 * and certificate verification. |
| 58 */ | 52 */ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void InitializeBuffers(Dart_Handle dart_this); | 118 void InitializeBuffers(Dart_Handle dart_this); |
| 125 void InitializePlatformData(); | 119 void InitializePlatformData(); |
| 126 | 120 |
| 127 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 121 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
| 128 }; | 122 }; |
| 129 | 123 |
| 130 } // namespace bin | 124 } // namespace bin |
| 131 } // namespace dart | 125 } // namespace dart |
| 132 | 126 |
| 133 #endif // BIN_SECURE_SOCKET_H_ | 127 #endif // BIN_SECURE_SOCKET_H_ |
| OLD | NEW |