Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
dart::bin::SecureSocketUtils Class Reference

#include <secure_socket_utils.h>

Inheritance diagram for dart::bin::SecureSocketUtils:
dart::AllStatic

Static Public Member Functions

static void ThrowIOException (int status, const char *exception_type, const char *message, const SSL *ssl)
 
static void CheckStatusSSL (int status, const char *type, const char *message, const SSL *ssl)
 
static void CheckStatus (int status, const char *type, const char *message)
 
static bool IsCurrentTimeInsideCertValidDateRange (X509 *root_cert)
 
static bool NoPEMStartLine ()
 
static uint32_t FetchErrorString (const SSL *ssl, TextBuffer *text_buffer)
 

Static Public Attributes

static constexpr int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000
 

Detailed Description

Definition at line 26 of file secure_socket_utils.h.

Member Function Documentation

◆ CheckStatus()

void dart::bin::SecureSocketUtils::CheckStatus ( int  status,
const char *  type,
const char *  message 
)
static

Definition at line 97 of file secure_socket_utils.cc.

99 {
101}
static void CheckStatusSSL(int status, const char *type, const char *message, const SSL *ssl)
Win32Message message

◆ CheckStatusSSL()

void dart::bin::SecureSocketUtils::CheckStatusSSL ( int  status,
const char *  type,
const char *  message,
const SSL *  ssl 
)
static

Definition at line 78 of file secure_socket_utils.cc.

81 {
82 // TODO(24183): Take appropriate action on failed calls,
83 // throw exception that includes all messages from the error stack.
84 if (status == 1) {
85 return;
86 }
87 if (SSL_LOG_STATUS) {
88 int error = ERR_get_error();
89 Syslog::PrintErr("Failed: %s status: %d ", message, status);
90 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE];
91 ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE);
92 Syslog::PrintErr("%s\n", error_string);
93 }
95}
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static constexpr int SSL_ERROR_MESSAGE_BUFFER_SIZE
static void ThrowIOException(int status, const char *exception_type, const char *message, const SSL *ssl)
const uint8_t uint32_t uint32_t GError ** error
const bool SSL_LOG_STATUS

◆ FetchErrorString()

uint32_t dart::bin::SecureSocketUtils::FetchErrorString ( const SSL *  ssl,
TextBuffer text_buffer 
)
static

Definition at line 27 of file secure_socket_utils.cc.

28 {
29 const char* sep = File::PathSeparator();
30 uint32_t errCode = 0;
31 while (true) {
32 const char* path = nullptr;
33 int line = -1;
34 uint32_t error = ERR_get_error_line(&path, &line);
35 if (error == 0) {
36 break;
37 }
38 if (errCode == 0) {
39 errCode = error;
40 }
41 text_buffer->Printf("\n\t%s", ERR_reason_error_string(error));
42 if ((ssl != nullptr) && (ERR_GET_LIB(error) == ERR_LIB_SSL) &&
43 (ERR_GET_REASON(error) == SSL_R_CERTIFICATE_VERIFY_FAILED)) {
44 intptr_t result = SSL_get_verify_result(ssl);
45 text_buffer->Printf(": %s", X509_verify_cert_error_string(result));
46 }
47 if ((path != nullptr) && (line >= 0)) {
48 const char* file = strrchr(path, sep[0]);
49 path = file != nullptr ? file + 1 : path;
50 text_buffer->Printf("(%s:%d)", path, line);
51 }
52 }
53 return errCode;
54}
static const char * PathSeparator()
GAsyncResult * result
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ IsCurrentTimeInsideCertValidDateRange()

bool dart::bin::SecureSocketUtils::IsCurrentTimeInsideCertValidDateRange ( X509 *  root_cert)
static

Definition at line 103 of file secure_socket_utils.cc.

103 {
104 ASN1_TIME* not_before = X509_get_notBefore(root_cert);
105 ASN1_TIME* not_after = X509_get_notAfter(root_cert);
106 int days_since_valid = 0;
107 int secs_since_valid = 0;
108 int days_before_invalid = 0;
109 int secs_before_invalid = 0;
110 // nullptr indicates current date/time
111 ASN1_TIME_diff(&days_since_valid, &secs_since_valid, not_before,
112 /*to=*/nullptr);
113 ASN1_TIME_diff(&days_before_invalid, &secs_before_invalid,
114 /*from=*/nullptr, not_after);
115 return days_since_valid >= 0 && secs_since_valid >= 0 &&
116 days_before_invalid >= 0 && secs_before_invalid >= 0;
117}

◆ NoPEMStartLine()

static bool dart::bin::SecureSocketUtils::NoPEMStartLine ( )
inlinestatic

Definition at line 44 of file secure_socket_utils.h.

44 {
45 uint32_t last_error = ERR_peek_last_error();
46 return (ERR_GET_LIB(last_error) == ERR_LIB_PEM) &&
47 (ERR_GET_REASON(last_error) == PEM_R_NO_START_LINE);
48 }

◆ ThrowIOException()

void dart::bin::SecureSocketUtils::ThrowIOException ( int  status,
const char *  exception_type,
const char *  message,
const SSL *  ssl 
)
static

Definition at line 57 of file secure_socket_utils.cc.

60 {
61 Dart_Handle exception;
62 {
63 TextBuffer error_string(SSL_ERROR_MESSAGE_BUFFER_SIZE);
64 uint32_t errCode = SecureSocketUtils::FetchErrorString(ssl, &error_string);
65 if (status == 0) {
66 status = errCode;
67 }
68 OSError os_error_struct(status, error_string.buffer(), OSError::kBoringSSL);
69 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct);
70 exception =
71 DartUtils::NewDartIOException(exception_type, message, os_error);
72 ASSERT(!Dart_IsError(exception));
73 }
74 Dart_ThrowException(exception);
76}
#define UNREACHABLE()
Definition assert.h:248
static Dart_Handle NewDartOSError()
Definition dartutils.cc:706
static Dart_Handle NewDartIOException(const char *exception_name, const char *message, Dart_Handle os_error)
Definition dartutils.cc:762
static uint32_t FetchErrorString(const SSL *ssl, TextBuffer *text_buffer)
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
#define ASSERT(E)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)

Member Data Documentation

◆ SSL_ERROR_MESSAGE_BUFFER_SIZE

constexpr int dart::bin::SecureSocketUtils::SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000
staticconstexpr

Definition at line 28 of file secure_socket_utils.h.


The documentation for this class was generated from the following files: