Skip to contentSkip to conversation

OpenVPN GUI not working with ms cert store

Openvpn-devel Mathias Sundman 2 participants 3 messages Nov 8, 2004

lore
Share & tools
lore
#0 lore raw

I got an email from an OpenVPN GUI user today saying that it didn't work together with passphrase protected keys in the MS certificate store.

I had no problem reproducing it. I'm using OpenVPN 2.0-beta16, and all version of OpenVPN GUI from beta1 to beta22 fails.

What happends is that OpenVPN "hangs" when windows is supposed to show the dialog asking the user to enter his passphrase.

If openvpn is run from cmd-line it works fine, and the passphrase dialog is showed, and even Michael's .NET based GUI works!

But not mine ;-( For some reason the dialog is just not showed, so obviously openvpn can't continue.

I just can't see really why, so there for I ask here if anyone got a clue why that would fail?

My guesses are:

1. I do something wrong when launching OpenVPN with CreateProcess().

2. Windows has found that the GUI started the openvpn process and is sending some message that I need to respone to in a certain way, that .NET handles internally which would explain why Michael's GUI works, but not mine.

To ease debugging we can use OpenVPN GUI 1.0-beta1 as referance. It is almost a copy of the openvpn service wrapper, with just some code to show the tray icon and a basic windows message loop.

Here is how I lauch the openvpn process:

/* fill in STARTUPINFO struct */ GetStartupInfo(&start_info);
start_info.cb = sizeof(start_info); start_info.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; start_info.wShowWindow = SW_HIDE; start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); start_info.hStdOutput = start_info.hStdError = log_handle;

/* create an OpenVPN process for one config file */ if (!CreateProcess(exe_path,
command_line,
NULL,
NULL,
TRUE,
priority | CREATE_NEW_CONSOLE,
NULL,
config_dir,
&start_info,
&proc_info))

  {
    ERR ("CreateProcess failed, exe='%s' cmdline='%s' dir='%s'",
      exe_path,
      command_line,
      config_dir);

    FindClose (find_handle);
    CloseHandle (log_handle);
    goto finish;

}

and here is my windows message callback function:

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {

  switch (message) {
    case WM_CREATE:
      TRAY_Init(hwnd); 		// Create tray icon and popup menu
      ShowTrayIcon();
      break;

    case WM_NOTIFYICONTRAY:
      OnNotifyTray(lParam); 	// Manages message from tray
      return TRUE;

    case WM_COMMAND:
      switch(LOWORD(wParam)) {
        case IDM_CONNECT:
          StartOpenVPN();
          break;
        case IDM_DISCONNECT:
          StopOpenVPN();
          break;
        case IDM_CLOSE:
          SendMessage(hwnd, WM_CLOSE, 0, 0);
          break;
      }
      break;

    case WM_DESTROY:
      StopOpenVPN();
      OnDestroyTray();          // Clean Tray related
      PostQuitMessage (0);	// Send a WM_QUIT to the message queue
      break;
    default:			// for messages that we don't deal with
      return DefWindowProc (hwnd, message, wParam, lParam);

}

return 0;
}

Best Regards,

Mathias

--
_____________________________________________________________

Mathias Sundman                  (^)   ASCII Ribbon Campaign
OpenVPN GUI for Windows           X    NO HTML/RTF in e-mail
http://www.nilings.se/openvpn    / \   NO Word docs in e-mail
#1 lore raw
Quoted 9 lines · Mathias Sundman

I got an email from an OpenVPN GUI user today saying that it didn't work together with passphrase protected keys in the MS certificate store.

I had no problem reproducing it. I'm using OpenVPN 2.0-beta16, and all version of OpenVPN GUI from beta1 to beta22 fails.

What happends is that OpenVPN "hangs" when windows is supposed to show the dialog asking the user to enter his passphrase.

If openvpn is run from cmd-line it works fine, and the passphrase dialog is showed, and even Michael's .NET based GUI works!

But not mine ;-( For some reason the dialog is just not showed, so obviously openvpn can't continue.

Why do one always find the problem yourself the minute after posting to a list?!

The problem was in the way I called CreateProcess(). I used the dwFlags = STARTF_USESHOWWINDOW and wShowWindow = SW_HIDE in the start_info struct.

This was no-no! It seemed to suppress also windows dialogs!

If I instead used CREATE_NO_WINDOW as dwCreationFlags in the call to CreateProcess(), then the openvpn console window was still hidden, but Windows still shows the certficate store dialogs correctly.

Thanks to the list for just existing ;-)

There will soon be a new release available of OpenVPN GUI with the fix included...

/Mathias

#2 lore raw
Quoted 1 line · Mathias Sundman

On Mon, 8 Nov 2004, Mathias Sundman wrote:

[SNIP]

Quoted 13 lines

Why do one always find the problem yourself the minute after posting to a list?!

The problem was in the way I called CreateProcess(). I used the dwFlags = STARTF_USESHOWWINDOW and wShowWindow = SW_HIDE in the start_info struct.

This was no-no! It seemed to suppress also windows dialogs!

If I instead used CREATE_NO_WINDOW as dwCreationFlags in the call to CreateProcess(), then the openvpn console window was still hidden, but Windows still shows the certficate store dialogs correctly.

Quoted 6 lines

Thanks to the list for just existing ;-)

There will soon be a new release available of OpenVPN GUI with the fix included...

/Mathias

[SNIP]

I'd guess different mindset. Sort of like verbally explaining it to some one and then it hits you.

Signature · 2 lines
Leonard Isham, CISSP
Ostendo non ostento.