FreeRDP / FreeRDP

FreeRDP is a free remote desktop protocol library and clients

Home Page:http://www.freerdp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FreeRDP console error ( OpenSSL LEGACY provider failed to load, no md4 support available! )

denis-limanov opened this issue · comments

Hello! I have C++ code using the FreeRDP library.

I installed FreeRDP 3.4.0 using vcpkg, wrote code to connect to RDP from the console, but when I compiled and ran the console application, I received an error message.

Error message:

[20:09:06:227] [10560:00002094] [WARN][com.winpr.utils.ssl] - [winpr_openssl_initialize]: OpenSSL LEGACY provider failed to load, no md4 support available!
[20:09:08:514] [10560:00002094] [ERROR][com.freerdp.core] - [freerdp_tcp_is_hostname_resolvable]: ERRCONNECT_DNS_NAME_NOT_FOUND [0x00020005]
[20:09:10:794] [10560:00002094] [ERROR][com.freerdp.core.nego] - [nego_connect]: Failed to connect
Failed to connect to 1.

When installing FreeRdp using vkpkg, OpenSSL is also installed accordingly.

The code itself:

#include <freerdp/freerdp.h>
#include <freerdp/client.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/winsock.h>
#include <iostream>



bool connect_to_rdp(const char* hostname, const char* username, const char* password, const char* domain) {
    freerdp* instance = freerdp_new();
    if (!instance) {
        std::cerr << "Failed to create FreeRDP instance.\n";
        return false;
    }

    if (!freerdp_context_new(instance)) {
        freerdp_free(instance);
        std::cerr << "Failed to create FreeRDP context.\n";
        return false;
    }


    freerdp_settings_set_string(instance->context->settings, FreeRDP_ServerHostname, hostname);
    freerdp_settings_set_string(instance->context->settings, FreeRDP_Username, username);
    freerdp_settings_set_string(instance->context->settings, FreeRDP_Password, password);
    freerdp_settings_set_string(instance->context->settings, FreeRDP_Domain, domain);
    freerdp_settings_set_bool(instance->context->settings, FreeRDP_IgnoreCertificate, TRUE);


    if (freerdp_connect(instance)) {
        std::cout << "Successfully connected to " << hostname << ".\n";
        freerdp_disconnect(instance);
        freerdp_free(instance);
        return true;
    } else {
        std::cerr << "Failed to connect to " << hostname << ".\n";
        freerdp_free(instance);
        return false;
    }
}

int main(int argc, char* argv[]) {
    if (argc < 5) {
        std::cerr << "Usage: " << argv[0] << " <hostname> <username> <password> <domain>\n";
        return -1;
    }

    WSADATA wsaData;
    WSAStartup(MAKEWORD(2, 2), &wsaData);

    bool success = connect_to_rdp(argv[1], argv[2], argv[3], argv[4]);

    WSACleanup();

    return success ? 0 : 1;
}

My tasks.json:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe сборка активного файла",
            "command": "c:\\msys64\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-lwsock32",
                "-I",
                "C:\\vcpkg\\installed\\x64-windows\\include\\openssl", // openssl
                "-L",
                "C:\\vcpkg\\installed\\x64-windows\\lib",
                "-lcrypto",
                "-lssl",
                "-lWs2_32",
                "-I",
                "C:\\vcpkg\\installed\\x64-windows\\include",
                "-L",
                "C:\\vcpkg\\installed\\x64-windows\\lib",
                "-lfreerdp3",
                "-lfreerdp-client3",
                "-lcjson",
                "-llibusb-1.0",
                "-lzlib",
                "-lwinpr3",
                "-Wl,--subsystem,windows"


            ],
            "options": {
                "cwd": "c:\\msys64\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Задача создана отладчиком."
        }
    ],
    "version": "2.0.0"
}

My settings.json:

{
    "C_Cpp.default.compilerPath": "C:\\msys64\\mingw64\\bin\\g++.exe",
    "files.associations": {
        "iosfwd": "cpp",
        "ostream": "cpp",
        "iostream": "cpp",
        "any": "cpp",
        "array": "cpp",
        "atomic": "cpp",
        "strstream": "cpp",
        "barrier": "cpp",
        "bit": "cpp",
        "*.tcc": "cpp",
        "bitset": "cpp",
        "cctype": "cpp",
        "cfenv": "cpp",
        "charconv": "cpp",
        "chrono": "cpp",
        "cinttypes": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "codecvt": "cpp",
        "compare": "cpp",
        "complex": "cpp",
        "concepts": "cpp",
        "condition_variable": "cpp",
        "coroutine": "cpp",
        "csetjmp": "cpp",
        "csignal": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "deque": "cpp",
        "forward_list": "cpp",
        "list": "cpp",
        "map": "cpp",
        "set": "cpp",
        "string": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "expected": "cpp",
        "algorithm": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "regex": "cpp",
        "source_location": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "rope": "cpp",
        "slist": "cpp",
        "format": "cpp",
        "fstream": "cpp",
        "future": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "istream": "cpp",
        "latch": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "numbers": "cpp",
        "ranges": "cpp",
        "scoped_allocator": "cpp",
        "semaphore": "cpp",
        "shared_mutex": "cpp",
        "span": "cpp",
        "spanstream": "cpp",
        "sstream": "cpp",
        "stacktrace": "cpp",
        "stdexcept": "cpp",
        "stdfloat": "cpp",
        "stop_token": "cpp",
        "streambuf": "cpp",
        "syncstream": "cpp",
        "thread": "cpp",
        "typeindex": "cpp",
        "typeinfo": "cpp",
        "valarray": "cpp",
        "variant": "cpp"
    },
    "makefile.makefilePath": ""
}

My launch.json:

{
    "configurations": [
        {
            "name": "C/C++: g++.exe сборка и отладка активного файла",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "c:\\msys64\\mingw64\\bin",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Включить автоматическое форматирование для gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Задать для варианта приложения дизассемблирования значение Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe сборка активного файла"
        }
    ],
    "version": "2.0.0"
}

My c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\msys64\\mingw64\\include\\",
                "C:\\libssh2\\include",
                "C:\\msys64\\mingw64\\include/**",
                "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c17",
            "cppStandard": "c++23",
            "intelliSenseMode": "windows-gcc-x64",
            "compilerArgs": [
                //"-lwsock32",
                //"-lssh2",
                //"-I C:\\libssh2\\include"
            ]
        }
    ],
    "version": 4
}

# vcpkg list:

cjson:x64-windows 1.7.17 Ultralightweight JSON parser i
n ANSI C
freerdp:x64-windows 3.4.0#1 A free implementation of the R
emote Desktop Prot...
libusb:x64-windows 1.0.27#1 a cross-platform library to ac
cess USB devices
openssl:x64-windows 3.3.0 OpenSSL is an open source proj
ect that provides ...
pkgconf:x64-windows 2.2.0 pkgconf is a program which hel
ps to configure co...
vcpkg-cmake-config:x64-windows 2022-02-06#1
vcpkg-cmake-get-vars:x64-windows 2023-12-31
vcpkg-cmake:x64-windows 2023-05-04
vcpkg-msbuild:x64-windows 2023-08-08
vcpkg-pkgconfig-get-modules:x64-windows 2023-09-06
vcpkg-tool-meson:x64-windows 1.3.2#2 Meson build system
zlib:x64-windows 1.3.1 A compression library

# vcpkg version:

vcpkg package management program version 2024-03-14-7d353e869753e5609a1f1a057df3db8fd356e49d

See LICENSE.txt for license information.

I use:
Windows 10 x64
Visual Studio Code
Mingw GCC
vcpkg
FreeRDP 3.4.0

Who knows the solution? I would be very grateful for your help as I am new to C++

just as the error indicates, you need to properly configure your openssl.

RDP uses some outdated hash algorithms in some places.
we have the WITH_INTERNAL_MD4 et al options to compile them directly so no support in openssl is required.