Search code examples
c++uwpopensslc++-winrt

Use SSL_use_certificate_file function on a UWP C++/WinRT Blank app


When passing the certificate path to SSL_use_certificate_file It returns an error Input/Output error. I think this error has to do with C++/WinRT limiting permission on file systems. The framework forces you to access the file through the StorageFile library, While OPENSSL probably uses ofstream to read the certificate file contents.

Is there another function or work around of calling SSL_use_certificate_file without getting the Input/Output Error


Solution

  • This is the file permission limitation for UWP apps. OpenSSL is a third-party library, and it seems that it is using .NET API to access the file which is not allowed in UWP apps. Just talk from the UWP side, if you have to use OpenSSL to get you want, a solution for this scenario is that you might need to use Desktop Bridge.

    1. You will need to create a normal desktop app to use the OpenSSL to do what you want.
    2. Then package the desktop app and your UWP app together using Windows Application Packaging Project.
    3. After that, you could use app service to establish communication between the two apps. Pass the result you want from your desktop app to the UWP app.

    You may check Stefan Wick's blog for more details here: UWP with Desktop Extension – Part 3.