mirror of https://github.com/OpenVPN/openvpn-gui
Update OpenSSL initialization
- Set env variables such as OPENSSL_CONF and OPENSSL_MODULES - Replace deprecated initialization (since OpenSSL 1.1.0) by OpenSSL_init_crypto() Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/483/head
parent
d27fd21222
commit
24b9d06957
9
main.c
9
main.c
|
@ -53,8 +53,7 @@
|
|||
#include "as.h"
|
||||
|
||||
#ifndef DISABLE_CHANGE_PASSWORD
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
#endif
|
||||
|
||||
#define OVPN_EXITCODE_ERROR 1
|
||||
|
@ -287,9 +286,9 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
|
|||
|
||||
#ifndef DISABLE_CHANGE_PASSWORD
|
||||
/* Initialize OpenSSL */
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_crypto_strings();
|
||||
#endif
|
||||
set_openssl_env_vars();
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
||||
#endif /* DISABLE_CHANGE_PASSWORD */
|
||||
|
||||
/* The Window structure */
|
||||
wincl.hInstance = hThisInstance;
|
||||
|
|
25
misc.c
25
misc.c
|
@ -713,3 +713,28 @@ ImportConfigFile(const TCHAR* source, bool prompt_user)
|
|||
/* destroy popup menus, based on existing num_configs, rescan file list and recreate menus */
|
||||
RecreatePopupMenus();
|
||||
}
|
||||
|
||||
void
|
||||
set_openssl_env_vars()
|
||||
{
|
||||
struct {
|
||||
WCHAR *name;
|
||||
WCHAR *value;
|
||||
} ossl_env[] = {
|
||||
{L"OPENSSL_CONF", L"ssl\\openssl.cnf"},
|
||||
{L"OPENSSL_ENGINES", L"ssl\\engines"},
|
||||
{L"OPENSSL_MODULES", L"ssl\\modules"}
|
||||
};
|
||||
for (size_t i = 0; i < _countof(ossl_env); i++)
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
_wgetenv_s(&size, NULL, 0, ossl_env[i].name);
|
||||
if (size == 0)
|
||||
{
|
||||
WCHAR val[MAX_PATH] = {0};
|
||||
_sntprintf_0(val, L"%ls%ls", o.install_path, ossl_env[i].value);
|
||||
_wputenv_s(ossl_env[i].name, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
5
misc.h
5
misc.h
|
@ -81,4 +81,9 @@ void ImportConfigFile(const TCHAR* path, bool prompt_user);
|
|||
BOOL
|
||||
GetDlgItemTextUtf8(HWND hDlg, int id, LPSTR* str, int* len);
|
||||
|
||||
/*
|
||||
* Set env vars used by OpenSSL to sane values.
|
||||
*/
|
||||
void set_openssl_env_vars(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -78,6 +78,7 @@ ExpandOptions (void)
|
|||
ExpandString (o.log_dir, _countof(o.log_dir));
|
||||
ExpandString (o.editor, _countof(o.editor));
|
||||
ExpandString (o.log_viewer, _countof(o.log_viewer));
|
||||
ExpandString (o.install_path, _countof(o.install_path));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -185,6 +185,7 @@ typedef struct {
|
|||
|
||||
/* HKLM Registry values */
|
||||
TCHAR exe_path[MAX_PATH];
|
||||
TCHAR install_path[MAX_PATH];
|
||||
TCHAR global_config_dir[MAX_PATH];
|
||||
TCHAR priority_string[64];
|
||||
TCHAR ovpn_admin_group[MAX_NAME];
|
||||
|
|
15
registry.c
15
registry.c
|
@ -78,7 +78,6 @@ static int
|
|||
GetGlobalRegistryKeys()
|
||||
{
|
||||
TCHAR windows_dir[MAX_PATH];
|
||||
TCHAR openvpn_path[MAX_PATH];
|
||||
HKEY regkey;
|
||||
|
||||
if (!GetWindowsDirectory(windows_dir, _countof(windows_dir))) {
|
||||
|
@ -100,23 +99,23 @@ GetGlobalRegistryKeys()
|
|||
regkey = NULL;
|
||||
ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY);
|
||||
}
|
||||
if (!regkey || !GetRegistryValue(regkey, _T(""), openvpn_path, _countof(openvpn_path))
|
||||
|| _tcslen(openvpn_path) == 0)
|
||||
if (!regkey || !GetRegistryValue(regkey, _T(""), o.install_path, _countof(o.install_path))
|
||||
|| _tcslen(o.install_path) == 0)
|
||||
{
|
||||
/* error reading registry value */
|
||||
if (regkey)
|
||||
ShowLocalizedMsg(IDS_ERR_READING_REGISTRY);
|
||||
/* Use a sane default value */
|
||||
_sntprintf_0(openvpn_path, _T("%ls"), _T("C:\\Program Files\\OpenVPN\\"));
|
||||
_sntprintf_0(o.install_path, _T("%ls"), _T("C:\\Program Files\\OpenVPN\\"));
|
||||
}
|
||||
if (openvpn_path[_tcslen(openvpn_path) - 1] != _T('\\'))
|
||||
_tcscat(openvpn_path, _T("\\"));
|
||||
if (o.install_path[_tcslen(o.install_path) - 1] != _T('\\'))
|
||||
_tcscat(o.install_path, _T("\\"));
|
||||
|
||||
/* an admin-defined global config dir defined in HKLM\OpenVPN\config_dir */
|
||||
if (!regkey || !GetRegistryValue(regkey, _T("config_dir"), o.global_config_dir, _countof(o.global_config_dir)))
|
||||
{
|
||||
/* use default = openvpnpath\config */
|
||||
_sntprintf_0(o.global_config_dir, _T("%lsconfig"), openvpn_path);
|
||||
_sntprintf_0(o.global_config_dir, _T("%lsconfig"), o.install_path);
|
||||
}
|
||||
|
||||
if (!regkey || !GetRegistryValue(regkey, _T("ovpn_admin_group"), o.ovpn_admin_group, _countof(o.ovpn_admin_group)))
|
||||
|
@ -126,7 +125,7 @@ GetGlobalRegistryKeys()
|
|||
|
||||
if (!regkey || !GetRegistryValue(regkey, _T("exe_path"), o.exe_path, _countof(o.exe_path)))
|
||||
{
|
||||
_sntprintf_0(o.exe_path, _T("%lsbin\\openvpn.exe"), openvpn_path);
|
||||
_sntprintf_0(o.exe_path, _T("%lsbin\\openvpn.exe"), o.install_path);
|
||||
}
|
||||
|
||||
if (!regkey || !GetRegistryValue(regkey, _T("priority"), o.priority_string, _countof(o.priority_string)))
|
||||
|
|
Loading…
Reference in New Issue