0

I have a smartcard with a card reader and I decide to implement a client certificate in the latter.

The private key being stored in the card and the public key is stored in the server.

The application scenario is something like this:

  1. application send frames to the Linux server
  2. Linux server answer with a ramdom number
  3. application read private key from (smartcard or pem file) and encrypt received random number and send the result to the server.
  4. server try to decrypt the sent encrypted string via public key (pem file stored in the server) => if succeed access is granted else access is denied.

In my application, there is a mode of certificate authentication (static file .pem) and also uses the private key (also static .pem). I used openssl-net functions such as FromPrivateKey(string pem, string password) and PrivateEncrypt(byte[] msg, RSA.Padding padding) for read private key and encrypt data to send to the server.

The problem that is needed, is that I have no a priori way to export my private key in my smartcard since my pem file.

So after much research I understood that I should use instead of these functions type functions: "ENGINE_load_private_key" with engine "pkcs11."

So I have seen several examples of openssl configuration (eg http://openssl.6102.n7.nabble.com/Private-Key-from-Windows-Cert-Store-td20720.html) with pkcs11 (opensc, engine_pkcs11. so etc. ..) the trouble is that these configurations are for Linux.

Indeed, my need is to develop a client application windows WPF (written in C #) that can read the private key from the smartcard or from a PEM file.

developer
  • 4,744
  • 7
  • 40
  • 55
  • the smart card will need a reader, you will need to connect to the driver of the reader and unless that is provided with a .Net API then you are going to have to use unmanaged code to access the driver, all of this though is device specific and not a default part of the framework as far as I'm aware – MikeT May 17 '16 at 15:18
  • I found opensc, but I don't found any documentation how to use it with openssl in windows – developer May 17 '16 at 16:36

0 Answers0