Hello,

Here is a simple program that will make it easier for you....

The file in ca and pkcs12 parameters is found when using Hebrew.

Alon.

---
#include <Windows.h>

int main(void) {
        WCHAR cmdline[] =
L"s:\\Temp\\openvpn\\build-win32\\src\\openvpn\\.libs\\openvpn.exe
--dev tap --tls-client --ca c:\\temp\\עברית\\ניסוי.txt --pkcs12
c:\\temp\\עברית\\ניסוי.txt";
        STARTUPINFO si;
        PROCESS_INFORMATION pi;
        ZeroMemory(&si, sizeof(si));
        si.cb = sizeof(si);
        ZeroMemory(&pi, sizeof(pi));
        CreateProcessW(
                NULL,
                cmdline,
                NULL,
                NULL,
                TRUE,
                0,
                NULL,
                NULL,
                &si,
                &pi
        );
        return 0;
}
---

2012/4/27 Samuli Seppänen <sam...@openvpn.net>:
>
>> Hello Samuli,
>>
>> Curios: Did you manage to get it work using master without my patch?
>
> Nope, although I only tested it briefly. I'll try that again just in case.
>
>> If not, to make it easy...
>>
>> Use Windows Explorer and rename the key file to something non-ascii.
>> Then open openvpn configuration using UTF-8 editor and modify key file there.
>> This should work, as we do not use unicode/conversion command-line.
>>
>> Next step would be to remove the key from configuration and use it in
>> command-line.
>>
>> Alon.
>
> Thanks, I'll try that.
>
> Samuli
>
>>
>> 2012/4/27 Samuli Seppänen <sam...@openvpn.net>:
>>> Hi,
>>>
>>> As promised in yesterday's IRC meeting (summary coming today), I tested
>>> this patch on Windows 7 (64-bit). So far I've had no luck, but don't
>>> think the problems have anything to do with this patch.
>>>
>>> Anyways, I cross-compiled latest "master" with this patch applied and
>>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>>> install. The old "bin" directory was renamed to make sure none of it was
>>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>>> file to point to these files using Notepad (and later Wordpad).
>>>
>>> OpenVPN-GUI (Heiko's new version) detected the configuration file
>>> properly, showing "ääliö" as one available connection option. However,
>>> it output the following when trying to connect:
>>>
>>>    Options error: --tls-auth fails with 'ääliö.key': No such file or
>>> directory
>>>
>>> Git Bash showed the file as ??li?.key, which could mean Windows Explorer
>>> is using a single-byte character set.
>>>
>>> Windows command prompt shows the characters properly, but issuing
>>> "openvpn --config ääliö.ovpn" gives the same error as OpenVPN-GUI above,
>>> except that 'ääliö.key' shows faulty glyphs[1]. This also triggers an
>>> interesting bug in the command prompt[2]
>>>
>>> Anyways, as the Windows 7 install is English-language, I suspect it's
>>> using a single-byte character set instead of UCS-2. I'll continue
>>> debugging, but any pointers are obviously much appreciated!
>>>
>>> Samuli
>>>
>>> [1] <http://users.utu.fi/sjsepp/cmd.png>
>>> [2] Typing an "ä" or "ö" moves the (invisible) cursor forward one
>>> character, but each backspace will delete two characters instead of one.
>>> This does not happen until openvpn has been (unsuccessfully) started.
>>>
>>>
>>>> Discussed at [1].
>>>>
>>>> Use wmain under windows, drop the custom parsing and shell32 linkage.
>>>>
>>>> There is no need for gc magic as this allocation is static.
>>>>
>>>> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>>>>
>>>> Signed-off-by: Alon Bar-Lev <alon.bar...@gmail.com>
>>>> ---
>>>>  src/openvpn/Makefile.am     |    6 +++++-
>>>>  src/openvpn/openvpn.c       |   37 ++++++++++++++++++++++++++++++++++++-
>>>>  src/openvpn/openvpn.vcxproj |   10 ++++++----
>>>>  src/openvpn/options.c       |   27 ---------------------------
>>>>  4 files changed, 47 insertions(+), 33 deletions(-)
>>>>  mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
>>>>
>>>> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
>>>> index 4e485e7..0506b11 100644
>>>> --- a/src/openvpn/Makefile.am
>>>> +++ b/src/openvpn/Makefile.am
>>>> @@ -27,6 +27,10 @@ AM_CFLAGS = \
>>>>       $(OPTIONAL_CRYPTO_CFLAGS) \
>>>>       $(OPTIONAL_LZO_CFLAGS) \
>>>>       $(OPTIONAL_PKCS11_HELPER_CFLAGS)
>>>> +if WIN32
>>>> +# we want unicode entry point but not the macro
>>>> +AM_CFLAGS += -municode -UUNICODE
>>>> +endif
>>>>
>>>>  sbin_PROGRAMS = openvpn
>>>>
>>>> @@ -118,5 +122,5 @@ openvpn_LDADD = \
>>>>       $(OPTIONAL_DL_LIBS)
>>>>  if WIN32
>>>>  openvpn_SOURCES += openvpn_win32_resources.rc
>>>> -openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm 
>>>> -lshell32
>>>> +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
>>>>  endif
>>>> diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
>>>> index 3db1b86..6e70a58 100644
>>>> --- a/src/openvpn/openvpn.c
>>>> +++ b/src/openvpn/openvpn.c
>>>> @@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
>>>>   * @param argc - Commandline argument count.
>>>>   * @param argv - Commandline argument values.
>>>>   */
>>>> +static
>>>>  int
>>>> -main (int argc, char *argv[])
>>>> +openvpn_main (int argc, char *argv[])
>>>>  {
>>>>    struct context c;
>>>>
>>>> @@ -289,3 +290,37 @@ main (int argc, char *argv[])
>>>>    openvpn_exit (OPENVPN_EXIT_STATUS_GOOD);  /* exit point */
>>>>    return 0;                              /* NOTREACHED */
>>>>  }
>>>> +
>>>> +#ifdef WIN32
>>>> +int
>>>> +wmain (int argc, wchar_t *wargv[]) {
>>>> +  char **argv;
>>>> +  int ret;
>>>> +  int i;
>>>> +
>>>> +  if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
>>>> +    return 1;
>>>> +
>>>> +  for (i = 0; i < argc; i++)
>>>> +    {
>>>> +      int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, 
>>>> NULL, NULL);
>>>> +      argv[i] = malloc (n);
>>>> +      WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, 
>>>> NULL);
>>>> +    }
>>>> +
>>>> +  ret = openvpn_main(argc, argv);
>>>> +
>>>> +  for (i=0; i < argc; i++ )
>>>> +    {
>>>> +      free (argv[i]);
>>>> +    }
>>>> +  free(argv);
>>>> +
>>>> +  return ret;
>>>> +}
>>>> +#else
>>>> +int
>>>> +main (int argc, char *argv[]) {
>>>> +     return openvpn_main(argc, argv);
>>>> +}
>>>> +#endif
>>>> diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
>>>> old mode 100644
>>>> new mode 100755
>>>> index 51e19af..452876f
>>>> --- a/src/openvpn/openvpn.vcxproj
>>>> +++ b/src/openvpn/openvpn.vcxproj
>>>> @@ -18,12 +18,12 @@
>>>>    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
>>>>    <PropertyGroup 
>>>> Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" 
>>>> Label="Configuration">
>>>>      <ConfigurationType>Application</ConfigurationType>
>>>> -    <CharacterSet>MultiByte</CharacterSet>
>>>>      <WholeProgramOptimization>true</WholeProgramOptimization>
>>>> +    <CharacterSet>Unicode</CharacterSet>
>>>>    </PropertyGroup>
>>>>    <PropertyGroup 
>>>> Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" 
>>>> Label="Configuration">
>>>>      <ConfigurationType>Application</ConfigurationType>
>>>> -    <CharacterSet>MultiByte</CharacterSet>
>>>> +    <CharacterSet>Unicode</CharacterSet>
>>>>    </PropertyGroup>
>>>>    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
>>>>    <ImportGroup Label="ExtensionSettings">
>>>> @@ -56,12 +56,13 @@
>>>>        </PrecompiledHeader>
>>>>        <WarningLevel>Level3</WarningLevel>
>>>>        <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
>>>> +      
>>>> <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>>>>      </ClCompile>
>>>>      <ResourceCompile>
>>>>        
>>>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>>>      </ResourceCompile>
>>>>      <Link>
>>>> -      
>>>> <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>> +      
>>>> <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>>        
>>>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>>>>        <GenerateDebugInformation>true</GenerateDebugInformation>
>>>>        <SubSystem>Console</SubSystem>
>>>> @@ -80,12 +81,13 @@
>>>>        </PrecompiledHeader>
>>>>        <WarningLevel>Level3</WarningLevel>
>>>>        <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
>>>> +      
>>>> <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>>>>      </ClCompile>
>>>>      <ResourceCompile>
>>>>        
>>>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>>>      </ResourceCompile>
>>>>      <Link>
>>>> -      
>>>> <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>> +      
>>>> <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>>        
>>>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>>>>        <GenerateDebugInformation>true</GenerateDebugInformation>
>>>>        <SubSystem>Console</SubSystem>
>>>> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
>>>> index 25786f6..66241b4 100644
>>>> --- a/src/openvpn/options.c
>>>> +++ b/src/openvpn/options.c
>>>> @@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
>>>>  {
>>>>    int i, j;
>>>>
>>>> -#ifdef WIN32
>>>> -  /*
>>>> -   * Windows replaces Unicode characters in argv[] that are not present
>>>> -   * in the current codepage with '?'. Get the wide char command line and
>>>> -   * convert it to UTF-8 ourselves.
>>>> -   */
>>>> -  int wargc;
>>>> -  WCHAR **wargv;
>>>> -  char **uargv;
>>>> -
>>>> -  wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
>>>> -  if (wargv == NULL || wargc != argc)
>>>> -    usage ();
>>>> -
>>>> -  uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
>>>> -
>>>> -  for (i = 0; i < wargc; i++)
>>>> -    {
>>>> -      int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, 
>>>> NULL, NULL);
>>>> -      uargv[i] = gc_malloc (n, false, &options->gc);
>>>> -      WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, 
>>>> NULL);
>>>> -    }
>>>> -
>>>> -  LocalFree (wargv);
>>>> -  argv = uargv;
>>>> -#endif
>>>> -
>>>>    /* usage message */
>>>>    if (argc <= 1)
>>>>      usage ();
>
>

Reply via email to