I want to use KDSoap, which uses Qt, which uses OpenSSL, to use a web service that requires a secure connection, which is established using a key stored in USB HSM (SmartCard + Reader basically called Athena IDProtect Key 2.0).
I installed 64-bit OpenSSL from Shining Light Productions . Qt 5.8 can download it (I checked with QSslSocket ).
Problem
The problem is that even if it seems that the Qt network server should load the OpenSSL configuration file, it is not. In fact, I think OpenSSL is to blame here, not Qt because of the tests I did with the openssl tool provided.
First of all, the configuration is read because any syntax error in config makes the openssl tool complain about it the next time I run it. Secondly, with a clean configuration, this works:
C:\Users\brokenthorn>openssl engine dynamic -t -pre SO_PATH:C:\OpenSSL-Win64\bin\capi.dll -pre LOAD -post list_certs (dynamic) Dynamic engine loading support [Success]: SO_PATH:C:\OpenSSL-Win64\bin\capi.dll [Success]: LOAD Loaded: (capi) CryptoAPI ENGINE [ available ] Certificate 0 <No Friendly Name> Subject: C = RO, L = Mun. Constanta, O = SC MINI-FARM SRL, CN = Valentina Calin, serialNumber = 2006051670CV93, name = Valentina Calin, GN = Valentina, SN = Calin Issuer: C = RO, O = certSIGN, OU = certSIGN Qualified CA Class 3 G2, CN = certSIGN Qualified CA Class 3 G2 Certificate 1 <No Friendly Name> Subject: CN = DESKTOP-IF670KN\\brokenthorn Issuer: CN = DESKTOP-IF670KN\\brokenthorn [Success]: list_certs
But if I try to load the engine by identifier, after defining it in the configuration file, I get an error message stating that it cannot find the DLL file, except that it adds .dll.dll to the specified ID:
OpenSSL> engine -t -pre ID:capi -pre LOAD (dynamic) Dynamic engine loading support [Success]: ID:capi [Failure]: LOAD 4684:error:25078067:DSO support routines:WIN32_LOAD:could not load the shared library:.\crypto\dso\dso_win32.c:179:filename(capi.dll.dll) 4684:error:25070067:DSO support routines:DSO_load:could not load the shared library:.\crypto\dso\dso_lib.c:233: 4684:error:260B6084:engine routines:DYNAMIC_LOAD:dso not found:.\crypto\engine\eng_dyn.c:467: [ unavailable ]
Now I tried to create a copy of capi.dll and named it capi.dll.dll and the above command will start working:
OpenSSL> engine -t -pre ID:capi -pre LOAD (dynamic) Dynamic engine loading support [Success]: ID:capi [Success]: LOAD Loaded: (capi) CryptoAPI ENGINE [ available ]
My openssl.cfg is standard, with the exception of the last part, where I added kernel directives that should force OpenSSL to load the default CryptoAPI mechanism, which I need if I ever intend to open a secure socket using a key stored in HSM. I will put the full configuration here for full reference if something bad sticks out:
#
Now, OpenSSL should by default load the capi engine to initialize the library, which happens in every application that is associated with this OpenSSL (and does not call special procedures that download or disable the download of the default configuration file), including the openssl command-line tool.
I donβt know yet, but ultimately I should also make it the default crypto provider.
In any case, adding the above configuration, and also before that, of course, I get the following:
OpenSSL> engine -t (rdrand) Intel RDRAND engine [ available ] (dynamic) Dynamic engine loading support [ unavailable ]
This should not be. The dynamic mechanism was supposed to turn into a capi engine ... as OpenSSL docs say.
CSP also works for HSM. I can list the loaded CSPs like this:
C:\Users\brokenthorn>openssl engine dynamic -t -pre SO_PATH:C:\OpenSSL-Win64\bin\capi.dll -pre LOAD -post list_csps (dynamic) Dynamic engine loading support [Success]: SO_PATH:C:\OpenSSL-Win64\bin\capi.dll [Success]: LOAD Loaded: (capi) CryptoAPI ENGINE [ available ] Available CSPs: 0. Athena ASECard Crypto CSP, type 1 1. Microsoft Base Cryptographic Provider v1.0, type 1 2. Microsoft Base DSS and Diffie-Hellman Cryptographic Provider, type 13 3. Microsoft Base DSS Cryptographic Provider, type 3 4. Microsoft Base Smart Card Crypto Provider, type 1 5. Microsoft DH SChannel Cryptographic Provider, type 18 6. Microsoft Enhanced Cryptographic Provider v1.0, type 1 7. Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider, type 13 8. Microsoft Enhanced RSA and AES Cryptographic Provider, type 24 9. Microsoft RSA SChannel Cryptographic Provider, type 12 10. Microsoft Strong Cryptographic Provider, type 1 11. OpenSC CSP, type 1 [Success]: list_csps
Index 0 CSP is my HSP CSP. I also sent some simple commands using the openssl tool to HSM to confirm that it really works, and it does what it should (provider provider provider CSPI provider provider).
Any suggestions?