Hello,There are two widely used standards of accessing cryptographic devices: RSA Security Inc PKCS#11 and Microsoft Cryptographic Service Provider.
Currently openssl has a Microsoft CryptoAPI interface.PKCS#11 is a cross platform vendor independed interface, which is used by most smartcard enabled application that designed to run on none Microsoft environments. (http://www.rsasecurity.com/rsalabs/node.asp?id=2133)
There is another standard which is called opensc that is also used in order to access smartcards, but most smartcard vendors do not support this interface. opensc also supply PKCS#11 interface (http://www.opensc.org/files/doc/opensc.html#opensc.pkcs11) so that it should work if PKCS#11 support is added.
I took the opensc patch that was sent recently and converted it to support PKCS#11. Original post is http://openvpn.net/archive/openvpn-devel/2005-09/msg00018.html, based on http://openvpn.net/archive/openvpn-devel/2005-02/msg00000.html
The patch is suitable for running on Linux (tested) and on Windows (I don't have build environment, but it compiles and the PKCS#11 part works).
Another advantage of PKCS#11 is that you don't need to link openvpn with library (as with opensc), so it can be available if ssl available, without any configuration options.
This patch adds the following options: --pkcs11-provider provider - PKCS#11 provider to load. --pkcs11-slot-type type - how to find the correct slot, can be: id - by number. name - by slot name. label - by token label. --pkcs11-slot name - the slot name.--pkcs11-id-type type - how to find certificate and private key, can be:
id - by id, hex string. label - by label, string. --pkcs11-id name - the id to find. The following standalone options were added: --show-pkcs11-slots provider - show available slots.--show-pkcs11-objects provider slot - show available token objects.
I've removed the dialogs and user interactions that were added to the previous patches, in order to specify password you simply use the current openvpn methods, such as --askpass. If someone think it should be added, let's discuss it. I don't see any point in active VPN without smartcard available.
I also updated the openssl documentation, I hope my English is correct... :)
I will be glad if people will try this patch, especially people who tried the current opensc patch.
Since PKCS#11 is available in both Windows and Linux, I hope Windows users will also try this patch, it resolves some problems exists with running openvpn as service and using CryptoAPI, since the service does not need to access user store in order to fetch the certificate.
I am no expert in openssl, so I appreciate if some of you will look into the implementation... I may missed some procedures.
Please don't be alarm from the size of the patch, it contain the interface of PKCS#11 module (pkcs11.h, pkcs11f.h, pkcs11t.h, cryptoki.h, cryptoki-win32.h).
Waiting for feedback... Any comments will be appreciated. Best Regards, Alon Bar-Lev.
openvpn-2.0.2-pkcs11-20050911.patch.bz2
Description: Binary data