'Is it possible auto fill certificate use pin using the C# webbrowser component?

I have a program based on WinForms, and the user interacts with a browser based on the C# WebBrowser component. While browsing, the website requests a client certificate, the list of available certificates is displayed correctly, the user selects the desired certificate and lastly, enters the certificate use pin (in my case, it is mandatory).

I am trying to inject (auto fill) the PasswordBox from the certificate pin popup.

// Parent handler: Windows 10 modal dialog to enter the pin. Works correctly.
IntPtr parentHandler = FindWindowsEx(IntPtr.Zero, IntPtr.Zero, "Credential Dialog Xaml Host", null);

// I can never get a child of the handler, whatever it is, it always returns zero. I have tried differents class names. 
IntPtr firstChildForExample = FindWindowsEx(parentHandler, IntPtr.Zero, null, null);

I have verified that parentHandler is not zero. I have also checked with Spy++ and the identifier is correct.

Is it possible to get the children of this window? Is there another way to be able to inject the certificate pin into a WebBrowser?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source