Pkcs11Interop / pkcs11-logger

PKCS#11 logging proxy module
Apache License 2.0
42 stars 14 forks source link

What is the recommendation for paths with space? #20

Open pionl opened 3 months ago

pionl commented 3 months ago

Hi,

Ive got a path to pkcs11 with spaces, how is recommended way to pass this path to? Thank you

System.Environment.SetEnvironmentVariable("PKCS11_LOGGER_LIBRARY_PATH", pkcs11LibFixedPath);

I have tried several implementations based on this https://www.howtogeek.com/694949/how-to-escape-spaces-in-file-paths-on-the-windows-command-line/

0x00002784 : 0x000063cc : ****************************** 2024-08-21 20:10:54 ***
0x00002784 : 0x000063cc : PKCS11-LOGGER 2.2.0
0x00002784 : 0x000063cc : PKCS#11 logging proxy module
0x00002784 : 0x000063cc : Developed as a part of the Pkcs11Interop project
0x00002784 : 0x000063cc : Please visit www.pkcs11interop.net for more information
0x00002784 : 0x000063cc : ****************************** 2024-08-21 20:10:54 ***
0x00002784 : 0x000063cc : Unable to load C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll
0x000070b8 : 0x00006078 : ****************************** 2024-08-21 20:14:13 ***
0x000070b8 : 0x00006078 : PKCS11-LOGGER 2.2.0
0x000070b8 : 0x00006078 : PKCS#11 logging proxy module
0x000070b8 : 0x00006078 : Developed as a part of the Pkcs11Interop project
0x000070b8 : 0x00006078 : Please visit www.pkcs11interop.net for more information
0x000070b8 : 0x00006078 : ****************************** 2024-08-21 20:14:13 ***
0x000070b8 : 0x00006078 : Unable to load C:\Program^ Files\Yubico\Yubico^ PIV^ Tool\bin\libykcs11.dll
0x00006590 : 0x00007bac : ****************************** 2024-08-21 20:20:40 ***
0x00006590 : 0x00007bac : PKCS11-LOGGER 2.2.0
0x00006590 : 0x00007bac : PKCS#11 logging proxy module
0x00006590 : 0x00007bac : Developed as a part of the Pkcs11Interop project
0x00006590 : 0x00007bac : Please visit www.pkcs11interop.net for more information
0x00006590 : 0x00007bac : ****************************** 2024-08-21 20:20:40 ***
0x00006590 : 0x00007bac : Unable to load C:\Program_Files\Yubico\Yubico_PIV_Tool\bin\libykcs11.dll
0x00007b40 : 0x00004e08 : ****************************** 2024-08-21 20:21:56 ***
0x00007b40 : 0x00004e08 : PKCS11-LOGGER 2.2.0
0x00007b40 : 0x00004e08 : PKCS#11 logging proxy module
0x00007b40 : 0x00004e08 : Developed as a part of the Pkcs11Interop project
0x00007b40 : 0x00004e08 : Please visit www.pkcs11interop.net for more information
0x00007b40 : 0x00004e08 : ****************************** 2024-08-21 20:21:56 ***
0x00007b40 : 0x00004e08 : Unable to load C:\Program\ Files\Yubico\Yubico\ PIV\ Tool\bin\libykcs11.dll
0x0000713c : 0x000013c8 : ****************************** 2024-08-21 20:23:02 ***
0x0000713c : 0x000013c8 : PKCS11-LOGGER 2.2.0
0x0000713c : 0x000013c8 : PKCS#11 logging proxy module
0x0000713c : 0x000013c8 : Developed as a part of the Pkcs11Interop project
0x0000713c : 0x000013c8 : Please visit www.pkcs11interop.net for more information
0x0000713c : 0x000013c8 : ****************************** 2024-08-21 20:23:02 ***
0x0000713c : 0x000013c8 : Unable to load C:\Program` Files\Yubico\Yubico` PIV` Tool\bin\libykcs11.dll
0x00007d80 : 0x000079cc : ****************************** 2024-08-21 20:35:17 ***
0x00007d80 : 0x000079cc : PKCS11-LOGGER 2.2.0
0x00007d80 : 0x000079cc : PKCS#11 logging proxy module
0x00007d80 : 0x000079cc : Developed as a part of the Pkcs11Interop project
0x00007d80 : 0x000079cc : Please visit www.pkcs11interop.net for more information
0x00007d80 : 0x000079cc : ****************************** 2024-08-21 20:35:17 ***
0x00007d80 : 0x000079cc : Unable to load C:\\Program Files\\Yubico\\Yubico PIV Tool\\bin\libykcs11.dll
0x000062b4 : 0x000057fc : ****************************** 2024-08-21 20:36:11 ***
0x000062b4 : 0x000057fc : PKCS11-LOGGER 2.2.0
0x000062b4 : 0x000057fc : PKCS#11 logging proxy module
0x000062b4 : 0x000057fc : Developed as a part of the Pkcs11Interop project
0x000062b4 : 0x000057fc : Please visit www.pkcs11interop.net for more information
0x000062b4 : 0x000057fc : ****************************** 2024-08-21 20:36:11 ***
0x000062b4 : 0x000057fc : Unable to load C:\"Program Files"\Yubico\"Yubico PIV Tool"\bin\libykcs11.dll
jariq commented 3 months ago

Your first try seems to be the correct one:

0x00002784 : 0x000063cc : Unable to load C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll

However that error does not necessarily mean that there is a problem with a path. Loading of PKCS#11 library can fail because of many other issues. One of them for example could be that PKCS#11 library depends on some third party library that is not available in your system. If you want to get more details you would need to modify part of code that handles error returned by LoadLibraryA function and get those details by calling GetLastError function.

When it comes to Yubico's PKCS#11 library I remember that it needed "special" loading that I implemented in Pkcs11Interop as a part of https://github.com/Pkcs11Interop/Pkcs11Interop/pull/143. If that is the case, then the quickest fix would be to add C:\Program Files\Yubico\Yubico PIV Tool\bin\ to your PATH.

jariq commented 1 month ago

@pionl any update on this?