Improve error on failure
@@ -160,8 +160,19 @@ mongoc_secure_channel_setup_certificate_from_file (const char *filename)
NULL, /* pvStructInfo */
&blob_private_len); /* pcbStructInfo */
if (!success) {
- MONGOC_ERROR ("Failed to parse private key. Error 0x%.8X",
- GetLastError ());
+ LPTSTR msg = NULL;
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ NULL,
+ GetLastError (),
+ LANG_NEUTRAL,
+ (LPTSTR) &msg,
+ 0,
+ NULL);
+ MONGOC_ERROR (
+ "Failed to parse private key. %s (0x%.8X)", msg, GetLastError ());
+ LocalFree (msg);
goto fail;
}
@@ -845,6 +856,7 @@ mongoc_secure_channel_handshake_step_2 (mongoc_stream_tls_t *tls,
default: {
LPTSTR msg = NULL;
+
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ARGUMENT_ARRAY,
