Comments (3)
This code won't work because when you construct X509Certificate2
this way it does not have any private key associated with it:
byte[] certData = objectAttributes[0].GetValueAsByteArray();
X509Certificate2 x509Certificate2 = new X509Certificate2(certData);
RSA rsaPrivateKey = x509Certificate2.GetRSAPrivateKey();
You can try to use Pkcs11Interop.X509Store library (that's where you opened this issue) and use GetRSAPrivateKey
method on Pkcs11X509Certificate
class instead.
from pkcs11interop.x509store.
@jariq thanks for reply. Yesterday all time I work for this issue but i cant take private key in usb hardware. I dont have a HSM. I have a usb hardware this is image: http://mm.kamusm.gov.tr/surecler/aldim_ne_yapmaliyim/1.jpg
I can not create PinProvider. Can you give a sample ? how can I use Pkcs11Interop.X509Store by new or external projects for private key ?
from pkcs11interop.x509store.
I can not create PinProvider. Can you give a sample?
You need to create your own class that implements IPinProvider
interface. Simplest example:
using Net.Pkcs11Interop.Common;
namespace ConsoleApp1
{
public class SimplePinProvider : IPinProvider
{
private byte[] _pin = null;
public SimplePinProvider(string pin)
{
_pin = ConvertUtils.Utf8StringToBytes(pin);
}
public GetPinResult GetKeyPin(Pkcs11X509StoreInfo storeInfo, Pkcs11SlotInfo slotInfo, Pkcs11TokenInfo tokenInfo, Pkcs11X509CertificateInfo certificateInfo)
{
return new GetPinResult(false, _pin);
}
public GetPinResult GetTokenPin(Pkcs11X509StoreInfo storeInfo, Pkcs11SlotInfo slotInfo, Pkcs11TokenInfo tokenInfo)
{
return new GetPinResult(false, _pin);
}
}
}
How can I use Pkcs11Interop.X509Store by new or external projects for private key?
By referencing Pkcs11Interop.X509Store
nuget package.
from pkcs11interop.x509store.
Related Issues (19)
- Can't get keys from HSM HOT 16
- Pkcs11Interop 5.1.0 and Pkcs11Interop.X509Store v 0.2.0 Can't Integrate HOT 3
- System.IO.FileNotFoundException has been thrown while setting up the package HOT 4
- NotSupportedException thrown when sign xml file from SignedXmlTest HOT 2
- Pkcs11X509Store In .net core HOT 1
- Pkcs11Exception: Method C_Initialize returned CKR_GENERAL_ERROR
- Cannot Initialize Pkcs11X509Store instance "Unable to load 64-bit unmanaged library into 32-bit runtime" HOT 1
- Soap SSL HOT 1
- outdated Nuget package on nuget.org HOT 1
- Project README needs to be improved
- Add code sample for `CmsSigner` with custom `AsymmetricAlgorithm`
- Unable to get private key from Luna HSM via X509Store HOT 6
- Does X509Store is only in read-only session? HOT 2
- FindKey includes label HOT 4
- Using ECDSA with SignedXML HOT 3
- Add code sample for `CertificateRequest` signing HOT 1
- Fails to load tokens when there are unrecognized ones HOT 3
- Pkcs11X509Store certificate throw unauthorized (Anonymous) with client WCF authentication HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkcs11interop.x509store.