I am trying to use BouncyCastle
library for generating X509Certificate
in a .Net
application, meanwhile i want to use keys stored in HSM
.
My solution is generating EC
key-pair in HSM
, returning ECPoint
and key lable to .Net
application, and regenerate an elliptic key for signature generation.
After generating elliptic key, While checking its validity i got this error: UnManagedException: Public key presented not for certificate signature
. This is the part of code from which Error raises:
X509Certificate rootCertificate = new X509Certificate (
new X509CertificateStructure (
TBS_Structure,
AlgorithmID,
new BitDERString(signature));
rootCertificate.Verify(PublicKeyParam);
PublicKeyParam
is RSAKeyParameter
and rebuilt based on Exponent and Modolus extracted from the library which made key on HSM (and returned key parameters). rootCertificate
's algorithm is SHA256WithRSAandMGF1
.