Closed ENDaZONELT closed 5 years ago
@ENDaZONELT Thank you for your information
As I can see from log this can be HSM error. You've got CKR_GENERAL_ERROR
on public key importing. I cannot reproduce this error with my PKCS11 providers.
Can you try to create RSA public key in your HSM via Session.create
function and get class
attribute from created object?
const object = session.create({
token: false,
class: graphene.ObjectClass.PUBLIC_KEY,
keyType: graphene.KeyType.RSA,
private: false,
label: "RSA-Test-key",
id: Buffer.from("rsa-test-public-key"),
verify: true,
encrypt: true,
wrap: true,
publicExponent: Buffer.from("j2MS4Q5yM8bODfWWdwg9aHo3vBtuBeOkArnMKfgP0vPUGoi2Xe+vrHfSFKlb3kBjJVJcIYoEtU1POTtWlj1TnPfJl8vT/poumWAk+W8q20spuRfFA5X6sJvcgsr8XXeKG7IlSqvlE8ETRdPjH8QtOA2qYbzigqx1q0rQKJ5yZ60yivP8fxstb0tFQLJspfYh+tMi02zHPEksZZUjwZe1EkLJED9yZBvlORT6jHubnRkCiQ85rGHx1ADXY7wNa4pPJ8TXH5EUAoBdXW4ommjpXQBW2e7kTxTBmfQRHo22iKwB8CvAepW5zMYgBnKl7UuqpI3BPUaPD76gghybKeahPQ==", "base64")
modulus: Buffer.from([1,0,1]),
});
console.log(object.class);
Thank you for you response @microshine . What I try to do is to get a certificate (not to import public key) from HSM device. I have private key, public key and certificate on my device. And I need to retrieve a certificate from HSM device to sign a document. I know, that I can store a certificate in my application, but I want to have everything on my device.
node-webcrypto-p11
module returns Certificate with PublicKey
interface ICryptoCertificate {
type: CryptoCertificateFormat;
publicKey: NativeCryptoKey;
}
https://github.com/PeculiarVentures/node-webcrypto-p11/blob/master/lib/cert_storage.ts#L59
Found other way
@ENDaZONELT please share your solution for others.
Certificate is stored on HSM device and I need to get it for signing. But when I try to do that an error message occurs.
console log:
But there were no problems to get a certificate using session.find()