mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-01 12:51:12 +00:00
chore: port add_platform_root_certificates to 15711
This commit is contained in:
@@ -904,7 +904,7 @@ target_include_directories(libslic3r_gui PRIVATE Utils ${CMAKE_CURRENT_BINARY_DI
|
|||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_include_directories(libslic3r_gui SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../deps/WebView2/include)
|
target_include_directories(libslic3r_gui SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../deps/WebView2/include)
|
||||||
target_link_libraries(libslic3r_gui Advapi32 Crypt32)
|
target_link_libraries(libslic3r_gui Advapi32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES})
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES})
|
||||||
|
|||||||
@@ -15,19 +15,8 @@
|
|||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include <openssl/err.h>
|
#ifdef OPENSSL_CERT_OVERRIDE
|
||||||
#include <openssl/ssl.h>
|
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/x509err.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# ifndef NOMINMAX
|
|
||||||
# define NOMINMAX
|
|
||||||
# endif
|
|
||||||
# include <windows.h>
|
|
||||||
# include <wincrypt.h>
|
|
||||||
// wincrypt.h uses this token for a certificate-name property identifier.
|
|
||||||
# undef X509_NAME
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@@ -951,45 +940,6 @@ std::string Http::tls_system_cert_store()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Http::add_platform_root_certificates(SSL_CTX* ssl_context)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
X509_STORE* openssl_store = SSL_CTX_get_cert_store(ssl_context);
|
|
||||||
if (!openssl_store)
|
|
||||||
throw std::runtime_error("unable to get OpenSSL certificate store");
|
|
||||||
|
|
||||||
const auto load_store = [&](DWORD location) {
|
|
||||||
HCERTSTORE windows_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0,
|
|
||||||
location | CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG,
|
|
||||||
L"ROOT");
|
|
||||||
if (!windows_store)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PCCERT_CONTEXT windows_certificate = nullptr;
|
|
||||||
while ((windows_certificate = CertEnumCertificatesInStore(windows_store, windows_certificate)) != nullptr) {
|
|
||||||
const unsigned char* encoded = windows_certificate->pbCertEncoded;
|
|
||||||
X509* certificate = d2i_X509(nullptr, &encoded, static_cast<long>(windows_certificate->cbCertEncoded));
|
|
||||||
if (!certificate) {
|
|
||||||
ERR_clear_error();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ERR_clear_error();
|
|
||||||
if (X509_STORE_add_cert(openssl_store, certificate) != 1)
|
|
||||||
ERR_clear_error();
|
|
||||||
X509_free(certificate);
|
|
||||||
}
|
|
||||||
|
|
||||||
CertCloseStore(windows_store, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
load_store(CERT_SYSTEM_STORE_CURRENT_USER);
|
|
||||||
load_store(CERT_SYSTEM_STORE_LOCAL_MACHINE);
|
|
||||||
#else
|
|
||||||
(void)ssl_context;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Http::url_encode(const std::string &str)
|
std::string Http::url_encode(const std::string &str)
|
||||||
{
|
{
|
||||||
::CURL *curl = ::curl_easy_init();
|
::CURL *curl = ::curl_easy_init();
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
#include "libslic3r/Exception.hpp"
|
#include "libslic3r/Exception.hpp"
|
||||||
#include "libslic3r_version.h"
|
#include "libslic3r_version.h"
|
||||||
|
|
||||||
typedef struct ssl_ctx_st SSL_CTX;
|
|
||||||
|
|
||||||
#define MAX_SIZE_TO_FILE 3*1024
|
#define MAX_SIZE_TO_FILE 3*1024
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@@ -200,11 +198,6 @@ public:
|
|||||||
// Return empty string on success or error message on fail.
|
// Return empty string on success or error message on fail.
|
||||||
static std::string tls_global_init();
|
static std::string tls_global_init();
|
||||||
static std::string tls_system_cert_store();
|
static std::string tls_system_cert_store();
|
||||||
// Add platform root certificates to a standalone OpenSSL context. This
|
|
||||||
// supplements set_default_verify_paths() on platforms where OpenSSL does
|
|
||||||
// not use the native certificate store.
|
|
||||||
static void add_platform_root_certificates(SSL_CTX* ssl_context);
|
|
||||||
|
|
||||||
// converts the given string to an url_encoded_string
|
// converts the given string to an url_encoded_string
|
||||||
static std::string url_encode(const std::string &str);
|
static std::string url_encode(const std::string &str);
|
||||||
static std::string url_decode(const std::string &str);
|
static std::string url_decode(const std::string &str);
|
||||||
|
|||||||
Reference in New Issue
Block a user