I use KSP for generate a private key in a HSM, SafeNet Key Storage Provider in specific but when process end the private key is doesn't storage in HSM, this is storage in the machine. How to do for storage the private key in HSM?
CX509PrivateKey objPrivateKey = new CX509PrivateKeyClass();
CCspInformations objCSPs = new CCspInformationsClass();
CCspInformation objCSP = new CCspInformationClass();
objCSP.InitializeFromName("SafeNet Key Storage Provider");
objCSPs.Add(objCSP);
objPrivateKey.MachineContext = true;
objPrivateKey.CspInformations = objCSPs;
objPrivateKey.Length = 1024;
objPrivateKey.Create();