Comments (2)
I downloaded Pkcs11Interop V2.0.1 the other day along with the Pkcs7SignatureGenerator.
It is quite an old code which needs to be updated to use at least Pkcs11Interop 3.1.0.
I was hoping to use the KeyContainerName to get the private key ID via the Pkcs11Explorer.
I am not quite sure why would you want to do that but it should be fairly easy to map X509Certificate2
class instance to Certificate
class instance by comparing X509Certificate2.RawData
with Certificate.Data
.
Corresponding PrivateKey
class instance then can be found by comparing PrivateKey.Id
with Certificate.Id
and PrivateKey.Label
with Certificate.Label
. However please note that this may not always work because such association is not required by PKCS#11 specification. To be 100% sure you will need to compare also PrivateKey.PublicKey
with Certificate.PublicKey
.
It seems odd that accessing the HSM via the certificate's private key causes the Pkcs11Interop to return an empty slot list. It's as if accessing the private key like this opens a session which isn't closed properly.
It is rather unusual to use both CSP and PKCS#11 providers in single application because often they share the same underlying code and may be interfering. Such problems are not easy to troubleshoot without the assistance of device vendor.
from pkcs11interop.
Thanks for the heads up regarding v3 of pkcs11interop.dll. I just got v2 via a link on stackoverflow.
Your suggestion about converting the X509Certificate2 into a Certificate appears to have done the trick!
private PrivateKey GetCertPrivateKey()
{
PrivateKey certificatePrivateKey = null;
Certificate tmpCert = new Certificate("Foo", "Bar", this.signingCertificate.RawData);
foreach (PrivateKey pk in this.privateKeys)
{
if (tmpCert.PublicKey.Equals(pk.PublicKey))
{
certificatePrivateKey = pk;
break;
}
}
return certificatePrivateKey;
}
Thanks for your help,
Mark
from pkcs11interop.
Related Issues (20)
- Method C_OpenSession returned CKR_CRYPTOKI_NOT_INITIALIZED
- Pkcs11Interop is not supported on this platform HOT 25
- Missing attribute CKA_NAME_HASH_ALGORITHM
- problem in Pkcs11Interop with new dll from epass 2003
- CKR_OPERATION_NOT_INITIALIZED in multithreaded application
- Missing param represents object handle
- Method C_Login returned CKR_SESSION_HANDLE_INVALID
- Incorrect CK_VERSION string value
- Get Key Value From HSM
- Not able to use C_Sign with yubikey PIV slot with CKA_ALWAYS_AUTHENTICATE HOT 5
- Linux : NativeULong as System.UInt32 causes error while accessing CK_GCM_PARAMS structure from PKCS11 standards HOT 2
- mac os compile problem MAUI .net core 7.0 how to fix ?
- SafeNet Data Objects HOT 7
- ComputeDigest/CreateDigestInfo - with newest Pkcs11Interop - how to ?
- C_Sign returned CKR_OPERATION_NOT_INITIALIZED in multithreaded application
- C_Encrypt with AES mechanism always returns with CKR_GENERAL_ERROR HOT 1
- C_FindObjects does return with nothing while running application in docker
- C_FindObjects does return with nothing while running application in docker HOT 3
- session.Decrypt returning garbage characters appended in PKCS#11 Multipart Decryption with Pkcs11Interop v 4.x.x
- CKR_DATA_INVALID when attempting to sign data using SignPath Cryptoki library HOT 6
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.